home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2011-12-21 | 143.9 KB | 4,170 lines
function Sounds(clip) { if(clip == undefined) { trace("Sounds: Clip not found in constructor"); } this.clip = clip; clip.objSounds = this; this.sounds = []; this.groups = []; this.loops = []; this.muted = false; clip.onEnterFrame = function() { this.objSounds.evtEnterFrame(); }; } function Physics(baseClip, gravityX, gravityY, drag, collidableMasses, attractingMasses, framePaintCallback, defaultPaint) { this.baseClip = baseClip; this.gravityX = gravityX; this.gravityY = gravityY; this.drag = drag; this.collidableMasses = !collidableMasses ? false : true; this.attractingMasses = !attractingMasses ? false : true; this.attractionScale = 100; this.masses = []; this.springs = []; this.surfaces = []; this.framePaintCallback = framePaintCallback; this.defaultPaint = defaultPaint != undefined ? defaultPaint : true; this.biggestMassRadius = 0; this.paused = false; this.baseClip.physics = this; this.baseClip.onEnterFrame = function() { this.physics.step(); }; } function massSort(a, b) { return a.x > b.x; } function collisionSort(a, b) { if(a.massA.idx == b.massA.idx) { return a.massB.idx > b.massB.idx; } return a.massA.idx > b.massA.idx; } function Mass(x, y, radius, fixed, physics, collisionSet) { this.x = x; this.y = y; this.prevX = x; this.prevY = y; this.radius = radius; this.radiusSquared = radius * radius; this.fixed = fixed; this.depth = physics.baseClip.getNextHighestDepth(); this.physics = physics; this.collisionSet = collisionSet; this.mass = 1; this.friction = 0; this.attractionMass = 0; this.attractionMaxForce = 10; this.extForceX = 0; this.extForceY = 0; this.hasHitSurface = false; this.idx = this.physics.masses.length; if(radius > physics.biggestMassRadius) { physics.biggestMassRadius = radius; } this.vx = 0; this.vy = 0; this.springs = []; this.physics.masses.push(this); if(this.physics.defaultPaint) { this.clip = this.physics.baseClip.createEmptyMovieClip("mass" + this.depth,this.depth); this.clip.lineStyle(this.radius * 2,255,50); this.clip.moveTo(0,0); this.clip.lineTo(0,1); this.clip.owner = this; } } function Spring(mass1, mass2, physics, k, damperK) { this.mass1 = mass1; this.mass2 = mass2; this.k = 0.8; if(k != undefined) { this.k = k; } this.damperK = 0.2; if(damperK != undefined) { this.damperK = damperK; } this.depth = physics.baseClip.getNextHighestDepth(); this.physics = physics; this.mass1.springs.push(this); this.mass2.springs.push(this); this.physics.springs.push(this); this.naturalLength = this.currentLength(); if(this.physics.defaultPaint) { this.clip = this.physics.baseClip.createEmptyMovieClip("spring" + this.depth,this.depth); this.clip.owner = this; } } function Surface(x1, y1, x2, y2, physics, restitution, friction) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; this.friction = 0.9; this.restitution = 0.96; if(friction != undefined) { this.friction = friction; } if(restitution != undefined) { this.restitution = restitution; } this.depth = physics.baseClip.getNextHighestDepth(); this.physics = physics; this.physics.surfaces.push(this); if(this.physics.defaultPaint) { this.clip = this.physics.baseClip.createEmptyMovieClip("surface" + this.depth,this.depth); this.clip.owner = this; this.paint(); } this.update(); } function SpringBox(x, y, w, h, vx, vy, cornerRadius, springConstant, mass, collisionSet, physics) { this.physics = physics; this.m_tl = new Mass(x - w / 2,y - h / 2,cornerRadius,false,physics,collisionSet); this.m_tr = new Mass(x + w / 2,y - h / 2,cornerRadius,false,physics,collisionSet); this.m_bl = new Mass(x - w / 2,y + h / 2,cornerRadius,false,physics,collisionSet); this.m_br = new Mass(x + w / 2,y + h / 2,cornerRadius,false,physics,collisionSet); this.m_tl.mass = mass; this.m_tr.mass = mass; this.m_bl.mass = mass; this.m_br.mass = mass; this.m_tl.vx = vx; this.m_tr.vx = vx; this.m_bl.vx = vx; this.m_br.vx = vx; this.m_tl.vy = vy; this.m_tr.vy = vy; this.m_bl.vy = vy; this.m_br.vy = vy; this.s1 = new Spring(this.m_tl,this.m_tr,physics,springConstant); this.s2 = new Spring(this.m_tr,this.m_br,physics,springConstant); this.s3 = new Spring(this.m_br,this.m_bl,physics,springConstant); this.s4 = new Spring(this.m_bl,this.m_tl,physics,springConstant); this.s5 = new Spring(this.m_tl,this.m_br,physics,springConstant); this.s6 = new Spring(this.m_tr,this.m_bl,physics,springConstant); this.frontLeft = this.m_tl; this.frontRight = this.m_tr; } function SpringLine(x, y, dx, dy, vx, vy, cornerRadius, springConstant, mass, physics, collisionSet) { this.physics = physics; this.m_f = new Mass(x - dx / 2,y - dy / 2,cornerRadius,false,physics,collisionSet); this.m_b = new Mass(x + dx / 2,y + dy / 2,cornerRadius,false,physics,collisionSet); this.m_f.mass = mass; this.m_b.mass = mass; this.m_f.springItem = this; this.m_b.springItem = this; this.m_f.vx = vx; this.m_f.vy = vy; this.m_b.vx = vx; this.m_b.vy = vy; this.s1 = new Spring(this.m_f,this.m_b,physics,springConstant); } function makeSpringLine(mass_front, mass_back) { var _loc1_ = {m_f:mass_front,m_b:mass_back}; _loc1_.s1 = new Spring(_loc1_.m_f,_loc1_.m_b,mass_front.physics,0.7); _loc1_.getPosition = SpringLine.prototype.getPosition; return _loc1_; } function addSurfaces(clip, instancePrefix, physics, restitution, friction) { var _loc7_ = []; var _loc6_ = 0; var _loc1_ = clip[instancePrefix + _loc6_]; while(_loc1_ != undefined) { var _loc3_ = _loc1_.p1.holderToLocal(physics.baseClip); var _loc2_ = _loc1_.p2.holderToLocal(physics.baseClip); var _loc5_ = new Surface(_loc3_.x,_loc3_.y,_loc2_.x,_loc2_.y,physics,restitution,friction); _loc1_._visible = false; _loc7_.push(_loc5_); _loc6_ = _loc6_ + 1; _loc1_ = clip[instancePrefix + _loc6_]; } return _loc7_; } function setupLevelIndicators(levelsClip) { initLevelSO(); initAchievementsSO(); var _loc3_ = undefined; var _loc5_ = 21; var _loc4_ = 1; while(_loc3_ = levelsClip["l" + _loc4_]) { var _loc2_ = _root.arrLevels[_loc4_]; _loc3_.id = _loc4_; _loc3_.gotoAndStop(!_loc2_.available ? "unavailable" : "available"); _loc3_.txtLevel.text = Maths.formatNum(_loc4_,2); _loc3_.passed.gotoAndStop("unfinished"); if(_loc2_.passed) { _loc3_.passed.gotoAndStop("passed"); } if(_loc2_.perfect) { _loc3_.passed.gotoAndStop("perfect"); } if(_loc2_.fast) { _loc3_.passed.gotoAndStop("fast"); } if(_loc2_.perfect && _loc2_.fast) { _loc3_.passed.gotoAndStop("perfectfast"); } if(!_loc2_.passed && _loc2_.available && _loc4_ < _loc5_) { _loc5_ = _loc4_; } _loc4_ = _loc4_ + 1; } if(_root.workingOnLevel == undefined) { _root.workingOnLevel = _loc5_; } levelsClip["l" + _root.workingOnLevel].gotoAndStop("selected"); _root.levelTitle._alpha = 0; levels.onEnterFrame = function() { _root.delay = _root.delay - 1; _root.levelTitle._x = _root._xmouse; _root.levelTitle._y = _root._ymouse; if(_root.objTrans.transitioning) { return undefined; } if(Key.isDown(Keys.Enter)) { _root.objTrans.goto("game"); } if(Key.isDown(Keys.CursorLeft) || Key.isDown(Keys.A)) { selectLevel(-1,0); } if(Key.isDown(Keys.CursorRight) || Key.isDown(Keys.D)) { selectLevel(1,0); } if(Key.isDown(Keys.CursorUp) || Key.isDown(Keys.W)) { selectLevel(0,-1); } if(Key.isDown(Keys.CursorDown) || Key.isDown(Keys.S)) { selectLevel(0,1); } }; } function rollOverLevel(id) { _root.levelTitle.txtTitle.text = _root.arrLevels[id].title; _root.levelTitle.fadeIn(0.5); } function rollOutLevel() { _root.levelTitle.fadeOut(0.5); } function selectLevel(dx, dy) { if(_root.delay > 0) { return undefined; } _root.delay = 6; var _loc8_ = _root.arrLevels[_root.workingOnLevel]; var _loc12_ = _root.levels["l" + _loc8_.id]._x; var _loc11_ = _root.levels["l" + _loc8_.id]._y; var _loc9_ = 0; var _loc10_ = _loc8_.id; var _loc3_ = 0; while(_loc3_ < _loc8_.links.length) { var _loc2_ = _root.arrLevels[_loc8_.links[_loc3_]]; if(_loc2_.available) { var _loc5_ = _root.levels["l" + _loc2_.id]._x - _loc12_; var _loc4_ = _root.levels["l" + _loc2_.id]._y - _loc11_; var _loc7_ = Maths.vectorLength(_loc5_,_loc4_); _loc5_ /= _loc7_; _loc4_ /= _loc7_; var _loc6_ = Maths.dotProduct(_loc5_,_loc4_,dx,dy); if(_loc6_ >= 0.4) { if(_loc6_ > _loc9_) { _loc9_ = _loc6_; _loc10_ = _loc2_.id; } } } _loc3_ = _loc3_ + 1; } deselectLevels(_loc10_); _root.levels["l" + _loc10_].gotoAndStop("selected"); } function setupNeverPress(clip) { clip.item = 0; clip.btnNeverPress.clip = clip; clip.btnNeverPress.onRelease = nextNeverPress; clip.txtNeverPress.text = arrNeverPress[0]; } function nextNeverPress() { this.clip.item = this.clip.item + 1; if(this.clip.item < arrNeverPress.length) { this.clip.txtNeverPress.text = arrNeverPress[this.clip.item]; _root.objSounds.play("buzz"); } else { _root.achieved(14); _root.objSounds.play("cry"); switch(Maths.randomInt(0,4)) { case 0: this.clip.txtNeverPress.text = "*cry*"; break; case 1: this.clip.txtNeverPress.text = "*waa*"; break; case 2: this.clip.txtNeverPress.text = "*sob*"; break; case 3: this.clip.txtNeverPress.text = "*sniffle*"; break; case 4: this.clip.txtNeverPress.text = "*weep*"; } this.clip.tear.gotoAndPlay("cry"); } } function setupAchievements() { var _loc2_ = 1; while(_loc2_ < _root.arrAchievements.length) { clip = _root["a" + _loc2_]; if(_root.arrAchievements[_loc2_].complete) { clip.box.gotoAndStop("on"); } clip._alpha = 0; clip.fadeIn(1,"linear",Maths.randomNum(0,1.5)); _loc2_ = _loc2_ + 1; } } function achieved(id) { trace("Achievement " + id + " gained"); if(_root.arrAchievements[id].complete) { return undefined; } _root.trackPoint("Achievement_" + id); _root.kongregateStats.submit("Achievement" + id,1); _root.arrAchievements[id].complete = true; var _loc5_ = SharedObject.getLocal("hannainachoppa"); _loc5_.data.arrAchievements = _root.arrAchievements; _loc5_.flush(); _root.achievement.gotoAndPlay("anim"); _root.achievement.txtAchievementName.text = achievementName(id); var _loc3_ = 0; var _loc2_ = 0; while(_loc2_ < _root.arrAchievements.length) { if(_root.arrAchievements[_loc2_].complete) { _loc3_ = _loc3_ + 1; } _loc2_ = _loc2_ + 1; } if(_loc3_ >= _root.arrAchievements.length - 2) { achieved(13); Mouse.show(); _root.objTrans.goto("win"); } } function deselectLevels(exceptID) { var _loc3_ = undefined; var _loc2_ = 1; while(_loc3_ = _root.levels["l" + _loc2_]) { if(_loc2_ != exceptID) { _loc3_.gotoAndStop(!_root.arrLevels[_loc2_].available ? "unavailable" : "available"); } _loc2_ = _loc2_ + 1; } _root.curLevelID = exceptID; _root.workingOnLevel = curLevelID; } function passedLevel(id, perfect, fast) { var _loc3_ = _root.arrLevels[id]; _loc3_.passed = true; if(perfect) { _loc3_.perfect = true; } if(fast) { _loc3_.fast = true; } reportAllStatistics(false); _root.workingOnLevel = undefined; var _loc2_ = 0; while(_loc2_ < _loc3_.links.length) { _root.arrLevels[_loc3_.links[_loc2_]].available = true; _loc2_ = _loc2_ + 1; } var _loc4_ = SharedObject.getLocal("hannainachoppa"); _loc4_.data.arrLevels = _root.arrLevels; _loc4_.flush(); } function reportAllStatistics(includeAchievements) { var _loc5_ = 0; var _loc4_ = 0; var _loc6_ = 0; var _loc7_ = 0; trace("Reporting stats to Kongregate"); var _loc3_ = SharedObject.getLocal("hannainachoppa"); if(_loc3_.data.arrAchievements != undefined) { var _loc2_ = 1; while(_loc2_ < _loc3_.data.arrAchievements.length) { if(_loc3_.data.arrAchievements[_loc2_].complete) { if(includeAchievements) { _root.kongregateStats.submit("Achievement" + _loc2_,1); trace(" Achievement" + _loc2_ + " = 1"); } _loc7_ = _loc7_ + 1; } _loc2_ = _loc2_ + 1; } } if(_loc3_.data.arrLevels != undefined) { _loc2_ = 1; while(_loc2_ < _loc3_.data.arrLevels.length) { if(_loc3_.data.arrLevels[_loc2_].passed) { _loc5_ = _loc5_ + 1; } if(_loc3_.data.arrLevels[_loc2_].perfect) { _loc6_ = _loc6_ + 1; } if(_loc3_.data.arrLevels[_loc2_].fast) { _loc4_ = _loc4_ + 1; } _loc2_ = _loc2_ + 1; } } trace(" CompletedLevels = " + _loc5_); trace(" CompletedFastLevels = " + _loc4_); trace(" CompletedPerfectLevels = " + _loc6_); trace(" CompletedAchievements = " + _loc7_); _root.kongregateStats.submit("CompletedLevels",_loc5_); _root.kongregateStats.submit("CompletedFastLevels",_loc4_); _root.kongregateStats.submit("CompletedPerfectLevels",_loc6_); _root.kongregateStats.submit("CompletedAchievements",_loc7_); } function initLevelSO() { var _loc2_ = SharedObject.getLocal("hannainachoppa"); if(_loc2_.data.arrLevels == undefined) { _loc2_.data.arrLevels = [{dummy:true},{id:1,available:false,passed:false,perfect:false,fast:false,par:200,title:"Learning to Fly",links:[2,4]},{id:2,available:false,passed:false,perfect:false,fast:false,par:500,title:"Finesse of Flight",links:[1,3,5]},{id:3,available:false,passed:false,perfect:false,fast:false,par:450,title:"A Weighty Problem",links:[2,6]},{id:4,available:false,passed:false,perfect:false,fast:false,par:200,title:"Blustery Day",links:[1,5]},{id:5,available:false,passed:false,perfect:false,fast:false,par:400,title:"Gone Fishin\'",links:[2,4,6,7]},{id:6,available:false,passed:false,perfect:false,fast:false,par:700,title:"Pulling The Plug",links:[3,5]},{id:7,available:false,passed:false,perfect:false,fast:false,par:750,title:"Flight of the Bumblebee",links:[5,8,9,10]},{id:8,available:false,passed:false,perfect:false,fast:false,par:400,title:"Fan-tastic",links:[7]},{id:9,available:false,passed:false,perfect:false,fast:false,par:1200,title:"Raining Hard on a Tiny Planetoid",links:[7,10,11,12]},{id:10,available:false,passed:false,perfect:false,fast:false,par:700,title:"Cement Mixer",links:[7,9,13,11]},{id:11,available:false,passed:false,perfect:false,fast:false,par:250,title:"Yosamite SAM-Site",links:[9,12,14,10]},{id:12,available:false,passed:false,perfect:false,fast:false,par:540,title:"Beat the Lift",links:[9,11]},{id:13,available:false,passed:false,perfect:false,fast:false,par:650,title:"Magneto Completo",links:[10,15]},{id:14,available:false,passed:false,perfect:false,fast:false,par:2000,title:"Like Herding Cats, Erm, But With Sheep",links:[11,15,18]},{id:15,available:false,passed:false,perfect:false,fast:false,par:370,title:"Enclosed Box of Goo",links:[14,16,17,13]},{id:16,available:false,passed:false,perfect:false,fast:false,par:3500,title:"Rescue at Sea",links:[15,19,17]},{id:17,available:false,passed:false,perfect:false,fast:false,par:200,title:"Entrapment",links:[15,18,19,16]},{id:18,available:false,passed:false,perfect:false,fast:false,par:2000,title:"Running With Scissors",links:[14,17]},{id:19,available:false,passed:false,perfect:false,fast:false,par:2000,title:"The Crush-O-Tron",links:[17,20,16]},{id:20,available:false,passed:false,perfect:false,fast:false,par:500,title:"Deja Vu?",links:[19,21]},{id:21,available:false,passed:false,perfect:false,fast:false,par:4500,title:"The Cake is a Lie",links:[20]}]; _loc2_.data.arrLevels[1].available = true; _loc2_.flush(); } _root.arrLevels = _loc2_.data.arrLevels; } function initAchievementsSO() { var _loc2_ = SharedObject.getLocal("hannainachoppa"); if(_loc2_.data.arrAchievements == undefined) { _loc2_.data.arrAchievements = [{dummy:true},{id:1,complete:false},{id:2,complete:false},{id:3,complete:false},{id:4,complete:false},{id:5,complete:false},{id:6,complete:false},{id:7,complete:false},{id:8,complete:false},{id:9,complete:false},{id:10,complete:false},{id:11,complete:false},{id:12,complete:false},{id:13,complete:false},{id:14,complete:false},{id:15,complete:false}]; _loc2_.flush(); } _root.arrAchievements = _loc2_.data.arrAchievements; } function achievementName(id) { switch(id) { case 1: return "HOVERCHAMP"; case 2: return "SERVICES TO SUMMER"; case 3: return "MISSILE PROOF"; case 4: return "SHEEP FRIENDLY"; case 5: return "TOWER BUDDIE"; case 6: return "TOWER SUPERBUDDIE"; case 7: return "BAKER OF CAKE"; case 8: return "BEEN THERE DONE THAT"; case 9: return "PRETTY PERFECT"; case 10: return "PERFECTIONIST"; case 11: return "PRETTY BRISK"; case 12: return "UBERFAST"; case 13: return "OVERACHIEVER"; case 14: return "PRESSER OF BUTTONS"; case 15: return "DEV-FRIEND"; default: return "UNKNOWN"; } } function initSounds() { _root.objSounds = new Sounds(_root.soundHolder); _root.objSounds.registerSound("blade0"); _root.objSounds.registerSound("blade1"); _root.objSounds.registerSound("blade2"); _root.objSounds.registerSound("blade3"); _root.objSounds.registerSound("blade4"); _root.objSounds.registerSound("blade5"); _root.objSounds.registerSound("blade6"); _root.objSounds.registerSound("blade7"); _root.objSounds.registerSound("blade8"); _root.objSounds.registerSound("blade9"); _root.objSounds.registerSound("blade10"); _root.objSounds.registerSound("blade11"); _root.objSounds.registerSound("blade12"); _root.objSounds.registerSound("blade13"); _root.objSounds.registerSound("blade14"); _root.objSounds.registerSound("blade15"); _root.objSounds.registerSound("blade16"); _root.objSounds.registerSound("blade17"); _root.objSounds.registerSound("blade18"); _root.objSounds.registerSound("blade19"); _root.objSounds.registerSound("blade20"); _root.objSounds.registerGroup("blade",["blade0","blade1","blade2","blade3","blade4","blade5","blade6","blade7","blade8","blade9","blade10","blade11","blade12","blade13","blade14","blade15","blade16","blade17","blade18","blade19","blade20"]); _root.objSounds.registerSound("bee-buzz"); _root.objSounds.registerSound("bee-squish-1"); _root.objSounds.registerSound("bee-squish-2"); _root.objSounds.registerSound("bee-squish-3"); _root.objSounds.registerSound("bee-squish-4"); _root.objSounds.registerGroup("bee-squish",["bee-squish-1","bee-squish-2","bee-squish-3","bee-squish-4"]); _root.objSounds.registerSound("baa1"); _root.objSounds.registerSound("baa2"); _root.objSounds.registerSound("baa3"); _root.objSounds.registerSound("baa4"); _root.objSounds.registerSound("baa5"); _root.objSounds.registerGroup("baa",["baa1","baa2","baa3","baa4","baa5"]); _root.objSounds.registerSound("cry1"); _root.objSounds.registerSound("cry2"); _root.objSounds.registerSound("cry3"); _root.objSounds.registerSound("cry4"); _root.objSounds.registerSound("cry5"); _root.objSounds.registerSound("cry6"); _root.objSounds.registerGroup("cry",["cry1","cry2","cry3","cry4","cry5","cry6"]); _root.objSounds.registerSound("clink1"); _root.objSounds.registerSound("clink2"); _root.objSounds.registerSound("clink3"); _root.objSounds.registerSound("clink4"); _root.objSounds.registerGroup("clink",["clink1","clink2","clink3","clink4"]); _root.objSounds.registerGroup("clunk",["clink3","clink4"]); _root.objSounds.registerSound("music"); _root.objSounds.registerSound("buzz",10); _root.objSounds.registerSound("achievement",60); _root.objSounds.registerSound("cake-mix"); _root.objSounds.registerSound("net-fall"); _root.objSounds.registerSound("rollover-tick"); _root.objSounds.registerSound("rollover-tock"); _root.objSounds.registerSound("sam-hit"); _root.objSounds.registerSound("sam-launch"); _root.objSounds.registerSound("switch"); _root.objSounds.registerSound("trans-hide"); _root.objSounds.registerSound("trans-reveal"); _root.objSounds.registerSound("wind-loop"); _root.objSounds.registerSound("crushotron-rumble"); _root.objSounds.registerSound("crushotron-bang"); _root.objSounds.registerSound("scissors"); _root.objSounds.registerSound("ratchet-loop"); _root.objSounds.registerSound("winch-deploy"); _root.objSounds.registerSound("winch-attach",60); _root.objSounds.registerSound("winch-retract"); _root.objSounds.registerSound("voice-cake"); _root.objSounds.registerSound("voice-butter"); _root.objSounds.registerSound("voice-chocolate"); _root.objSounds.registerSound("voice-eggs"); _root.objSounds.registerSound("voice-flour"); _root.objSounds.registerSound("voice-sugar"); _root.objSounds.registerSound("voice-boom"); _root.objSounds.registerSound("voice-crashed"); _root.objSounds.registerSound("voice-noooo"); _root.objSounds.registerSound("voice-ouch"); _root.objSounds.registerSound("voice-ow"); _root.objSounds.registerSound("voice-watchit"); _root.objSounds.registerGroup("crashed",["voice-boom","voice-crashed","voice-noooo","voice-ouch","voice-ow","voice-watchit"]); _root.objSounds.registerSound("voice-complete"); _root.objSounds.registerSound("voice-perfect"); _root.objSounds.registerSound("voice-reallyfast"); _root.objSounds.registerSound("voice-title"); } function ChoppaGame(clip) { this.clip = clip; this.clip.objGame = this; this.initialise(); } stop(); Mouse.show(); _root.objSounds.stop("music"); var Maths = new Object(); Maths.randomNum = function(minNum, maxNum) { return Math.random() * (maxNum - minNum) + minNum; }; Maths.randomInt = function(minNum, maxNum) { return Math.round(Math.random() * (maxNum - minNum) + minNum); }; Maths.vectorLength = function(dx, dy) { return Math.sqrt(dx * dx + dy * dy); }; Maths.distance = function(x1, y1, x2, y2) { var _loc2_ = x1 - x2; var _loc1_ = y1 - y2; return Maths.vectorLength(_loc2_,_loc1_); }; Maths.vectorLengthSquared = function(dx, dy) { return dx * dx + dy * dy; }; Maths.distanceSquared = function(x1, y1, x2, y2) { var _loc2_ = x1 - x2; var _loc1_ = y1 - y2; return Maths.vectorLengthSquared(_loc2_,_loc1_); }; Maths.angleBetween = function(x1, y1, x2, y2) { var _loc2_ = x1 * x2 + y1 * y2; var _loc1_ = Maths.vectorLength(x1,y1) * Maths.vectorLength(x2,y2); return Math.acos(_loc2_ / _loc1_); }; Maths.dotProduct = function(ax, ay, bx, by) { return ax * bx + ay * by; }; Maths.vectorIntersect = function(v1, v2) { var _loc3_ = {dx:v2.x - v1.x,dy:v2.y - v1.y}; v1.len = Maths.vectorLength(v1.dx,v1.dy); v2.len = Maths.vectorLength(v2.dx,v2.dy); v1.nx = v1.dx / v1.len; v1.ny = v1.dy / v1.len; v2.nx = v2.dx / v2.len; v2.ny = v2.dy / v2.len; var _loc4_ = Maths.vectorPerp(_loc3_,v2) / Maths.vectorPerp(v1,v2); if(v1.nx == v2.nx && v1.ny == v2.ny || v1.nx == - v2.nx && v1.ny == - v2.ny) { _loc4_ = 1000000; } return {x:v1.x + v1.dx * _loc4_,y:v1.y + v1.dy * _loc4_,t:_loc4_}; }; Maths.vectorPerp = function(v1, v2) { return (- v1.dy) * v2.dx + v1.dx * v2.dy; }; Maths.vectorProject = function(v1, v2) { var _loc2_ = Maths.vectorLength(v2.dx,v2.dy); var _loc4_ = v2.dx / _loc2_; var _loc3_ = v2.dy / _loc2_; var _loc5_ = Maths.dotProduct(v1.dx,v1.dy,_loc4_,_loc3_); return {x:v2.x,y:v2.y,dx:_loc4_ * _loc5_,dy:_loc3_ * _loc5_}; }; Maths.formatNum = function(num, leadingDigits, decimalDigits) { var _loc2_ = "" + Math.floor(num); while(_loc2_.length < leadingDigits) { _loc2_ = "0" + _loc2_; } if(decimalDigits != undefined) { var _loc1_ = Math.abs(num) - Math.floor(Math.abs(num)); _loc1_ *= 10 ^ decimalDigits; _loc1_ = Math.floor(_loc1_); _loc1_ = "" + _loc1_; while(_loc1_.length < decimalDigits) { _loc1_ += "0"; } _loc2_ = _loc2_ + "." + _loc1_; } return _loc2_; }; Maths.degToRad = function(degs) { return degs * 0.017453292519943295; }; Maths.radToDeg = function(rads) { return rads * 57.29577951308232; }; MovieClip.prototype.drawCross = function(x, y, colour) { if(colour != undefined) { this.lineStyle(1,colour,100); } else { this.lineStyle(1,16711935,100); } var _loc2_ = 7; this.moveTo(x - _loc2_,y); this.lineTo(x + _loc2_,y); this.moveTo(x,y - _loc2_); this.lineTo(x,y + _loc2_); }; MovieClip.prototype.drawVector = function(v, scale, colour) { if(colour != undefined) { this.lineStyle(1,colour,100); } else { this.lineStyle(1,65280,100); } if(scale == undefined) { scale = 1; } this.moveTo(v.x,v.y); this.lineTo(v.x + v.dx * scale,v.y + v.dy * scale); }; MovieClip.prototype.curvedRectangle = function(p_nX1, p_nY1, p_nX2, p_nY2, p_nR) { var _loc2_ = p_nR != undefined ? p_nR : 0; var _loc7_ = _loc2_ * 2; var _loc10_ = Math.abs(p_nX2 - p_nX1) - _loc7_; var _loc8_ = Math.abs(p_nY2 - p_nY1) - _loc7_; this.moveTo(p_nX1 + _loc2_,p_nY1); this.lineTo(p_nX2 - _loc2_,p_nY1); this.curveTo(p_nX2,p_nY1,p_nX2,p_nY1 + _loc2_); this.lineTo(p_nX2,p_nY2 - _loc2_); this.curveTo(p_nX2,p_nY2,p_nX2 - _loc2_,p_nY2); this.lineTo(p_nX1 + _loc2_,p_nY2); this.curveTo(p_nX1,p_nY2,p_nX1,p_nY2 - _loc2_); this.lineTo(p_nX1,p_nY1 + _loc2_); this.curveTo(p_nX1,p_nY1,p_nX1 + _loc2_,p_nY1); }; MovieClip.prototype.drawSquare = function(x, y, w, h) { this.moveTo(x,y); this.lineTo(x + w,y); this.lineTo(x + w,y + h); this.lineTo(x,y + h); this.lineTo(x,y); }; MovieClip.prototype.drawFilledSquare = function(x, y, w, h, colour, alpha) { this.beginFill(colour,alpha); this.drawSquare(x,y,w,h); this.endFill(); }; MovieClip.prototype.drawCircle = function(x, y, r) { var _loc6_ = r * 0.41421356237309515; var _loc5_ = r * 1.4142135623730951 / 2; this.moveTo(x + r,y); this.curveTo(x + r,y + _loc6_,x + _loc5_,y + _loc5_); this.curveTo(x + _loc6_,y + r,x,y + r); this.curveTo(x - _loc6_,y + r,x - _loc5_,y + _loc5_); this.curveTo(x - r,y + _loc6_,x - r,y); this.curveTo(x - r,y - _loc6_,x - _loc5_,y - _loc5_); this.curveTo(x - _loc6_,y - r,x,y - r); this.curveTo(x + _loc6_,y - r,x + _loc5_,y - _loc5_); this.curveTo(x + r,y - _loc6_,x + r,y); }; MovieClip.prototype.drawFilledCircle = function(x, y, r, colour, alpha) { this.beginFill(colour,alpha); this.drawCircle(x,y,r); this.endFill(); }; MovieClip.prototype.drawCircleSegment = function(x, y, r, startAngle, endAngle, stepAngle) { degToRad = 0.017453292519943295; while(endAngle < startAngle) { endAngle += 360; } this.moveTo(x,y); this.lineTo(x + r * Math.cos(startAngle * degToRad),x + r * Math.sin(startAngle * degToRad)); var _loc2_ = startAngle + stepAngle; while(_loc2_ < endAngle - stepAngle) { var _loc3_ = _loc2_ * degToRad; this.lineTo(x + r * Math.cos(_loc3_),x + r * Math.sin(_loc3_)); _loc2_ += stepAngle; } this.lineTo(x + r * Math.cos(endAngle * degToRad),x + r * Math.sin(endAngle * degToRad)); this.lineTo(x,y); }; MovieClip.prototype.drawFilledCircleSegment = function(x, y, r, startAngle, endAngle, stepAngle, colour, alpha) { this.beginFill(colour,alpha); this.drawCircleSegment(x,y,r,startAngle,endAngle,stepAngle); this.endFill(); }; MovieClip.prototype.drawSmoothCurveThroughPoints = function(wibbleFactor, startAngle, points) { this.moveTo(points[0].x,points[0].y); var _loc13_ = points[0].x - Math.cos(3.141592653589793 * startAngle / 180); var _loc12_ = points[0].y - Math.sin(3.141592653589793 * startAngle / 180); var _loc2_ = 1; while(_loc2_ < points.length) { var _loc5_ = points[_loc2_ - 1].x - _loc13_; var _loc4_ = points[_loc2_ - 1].y - _loc12_; var _loc8_ = Maths.vectorLength(_loc5_,_loc4_); var _loc10_ = points[_loc2_ - 1].x - points[_loc2_].x; var _loc9_ = points[_loc2_ - 1].y - points[_loc2_].y; var _loc11_ = Maths.vectorLength(_loc10_,_loc9_); cScale = 0; if(_loc8_ != 0) { cScale = (0.5 + wibbleFactor) * _loc11_ / _loc8_; } var _loc7_ = points[_loc2_ - 1].x + _loc5_ * cScale; var _loc6_ = points[_loc2_ - 1].y + _loc4_ * cScale; this.curveTo(_loc7_,_loc6_,points[_loc2_].x,points[_loc2_].y); _loc13_ = _loc7_; _loc12_ = _loc6_; _loc2_ = _loc2_ + 1; } }; MovieClip.prototype.holderToLocal = function(clip) { var _loc2_ = {x:0,y:0}; this.localToGlobal(_loc2_); clip.globalToLocal(_loc2_); return _loc2_; }; MovieClip.prototype.holderToGlobal = function() { var _loc2_ = {x:0,y:0}; this.localToGlobal(_loc2_); return _loc2_; }; MovieClip.prototype.makeSound = function(soundLinkage, depth) { var _loc2_ = this.createEmptyMovieClip("soundClip_" + soundLinkage + "_" + depth + "_" + Math.floor(Maths.randomNum(1000000,9000000)),depth); _loc2_.sound = new Sound(_loc2_); _loc2_.sound.attachSound(soundLinkage); _loc2_.sound.sourceClip = _loc2_; return _loc2_.sound; }; var Keys = new Object(); Keys.LeftMouse = 1; Keys._mouseDown = false; Keys.onMouseDown = function() { this._mouseDown = true; }; Keys.onMouseUp = function() { this._mouseDown = false; }; Mouse.addListener(Keys); Keys.mouseDown = function() { return this._mouseDown; }; Keys.CursorLeft = 37; Keys.CursorRight = 39; Keys.CursorUp = 38; Keys.CursorDown = 40; Keys.Escape = 27; Keys.Backspace = 8; Keys.Tab = 9; Keys.Enter = 13; Keys.Shift = 16; Keys.Control = 17; Keys.Alt = 18; Keys.CapsLock = 20; Keys.Spacebar = 32; Keys.PageUp = 33; Keys.PageDown = 34; Keys.End = 35; Keys.Home = 36; Keys.PrintScr = 44; Keys.ScrollLock = 145; Keys.Pause = 19; Keys.Insert = 45; Keys.Delete = 46; Keys.NumLock = 144; Keys.Semicolon = 186; Keys.Equals = 187; Keys.Minus = 189; Keys.Slash = 191; Keys.Apostrophe = 192; Keys.BackTick = 223; Keys.BackSlash = 220; Keys.Hash = 222; Keys.Comma = 188; Keys.Period = 190; Keys.SquareOpen = 219; Keys.SquareClose = 221; Keys.F1 = 112; Keys.F2 = 113; Keys.F3 = 114; Keys.F4 = 115; Keys.F5 = 116; Keys.F6 = 117; Keys.F7 = 118; Keys.F8 = 119; Keys.F9 = 120; Keys.F10 = undefined; Keys.F11 = 122; Keys.F12 = 123; Keys.Num0 = 96; Keys.Num1 = 97; Keys.Num2 = 98; Keys.Num3 = 99; Keys.Num4 = 100; Keys.Num5 = 101; Keys.Num6 = 102; Keys.Num7 = 103; Keys.Num8 = 104; Keys.Num9 = 105; Keys.NumMultiply = 106; Keys.NumAdd = 107; Keys.NumEnter = 13; Keys.NumMinus = 109; Keys.NumPeriod = 110; Keys.NumDivide = 111; Keys.A = 65; Keys.B = 66; Keys.C = 67; Keys.D = 68; Keys.E = 69; Keys.F = 70; Keys.G = 71; Keys.H = 72; Keys.I = 73; Keys.J = 74; Keys.K = 75; Keys.L = 76; Keys.M = 77; Keys.N = 78; Keys.O = 79; Keys.P = 80; Keys.Q = 81; Keys.R = 82; Keys.S = 83; Keys.T = 84; Keys.U = 85; Keys.V = 86; Keys.W = 87; Keys.X = 88; Keys.Y = 89; Keys.Z = 90; Keys.Key0 = 48; Keys.Key1 = 49; Keys.Key2 = 50; Keys.Key3 = 51; Keys.Key4 = 52; Keys.Key5 = 53; Keys.Key6 = 54; Keys.Key7 = 55; Keys.Key8 = 56; Keys.Key9 = 57; Sounds.prototype.registerSound = function(linkage, defaultVolume) { if(defaultVolume == undefined) { defaultVolume = 100; } var _loc4_ = this.clip.getNextHighestDepth(); var _loc2_ = this.clip.createEmptyMovieClip(linkage + "_" + _loc4_,_loc4_); _loc2_.sound = new Sound(_loc2_); _loc2_.sound.defaultVolume = defaultVolume; _loc2_.sound.clip = _loc2_; _loc2_.sound.attachSound(linkage); _loc2_.sound.setVolume(defaultVolume); this.sounds[linkage] = _loc2_.sound; this.sounds[linkage].looping = false; this.sounds[linkage].playing = false; this.sounds[linkage].onSoundComplete = function() { if(this.looping) { this.start(); } else { this.playing = false; } }; return _loc2_.sound; }; Sounds.prototype.registerGroup = function(groupID, arrGroupIDs) { var _loc2_ = 0; while(_loc2_ < arrGroupIDs.length) { if(this.sounds[arrGroupIDs[_loc2_]] == undefined) { trace("Sounds: Group \'" + groupID + "\' contains non-registered sound ID \'" + arrGroupIDs[_loc2_] + "\'"); } _loc2_ = _loc2_ + 1; } this.groups[groupID] = arrGroupIDs; }; Sounds.prototype.play = function(id, volume, loop, soundPosition) { if(this.muted) { return undefined; } if(loop != undefined) { this.sounds[id].looping = loop; } if(soundPosition == undefined) { soundPosition = 0; } if(this.groups[id] != undefined) { id = this.groups[id][Maths.randomInt(0,this.groups[id].length - 1)]; } if(this.sounds[id] == undefined) { trace("Sounds: Trying to play unregistered sound \'" + id + "\'"); } if(volume != undefined) { this.sounds[id].setVolume(volume); } this.sounds[id].start(soundPosition); this.sounds[id].playing = true; }; Sounds.prototype.stop = function(id) { if(this.sounds[id] == undefined) { trace("Sounds: Trying to stop unregistered sound \'" + id + "\'"); } this.sounds[id].looping = false; this.sounds[id].stop(); this.sounds[id].playing = false; }; Sounds.prototype.volume = function(id, volume) { if(this.sounds[id] == undefined) { trace("Sounds: Trying to set volume of unregistered sound \'" + id + "\'"); } this.sounds[id].setVolume(volume); }; Sounds.prototype.fadeTo = function(id, volume, dVol) { if(this.sounds[id] == undefined) { trace("Sounds: Trying to fade volume of unregistered sound \'" + id + "\'"); } if(dVol == undefined) { dVol = 1; } this.sounds[id].dVol = Math.ceil(Math.abs(dVol)); this.sounds[id].targetVol = volume; }; Sounds.prototype.stopAllSounds = function() { for(id in this.sounds) { this.stop(id); } }; Sounds.prototype.fadeOutAllSounds = function(dVol) { for(id in this.sounds) { this.fadeTo(id,0,dVol); } }; Sounds.prototype.setMute = function(muted) { this.muted = muted; if(this.muted) { this.stopAllSounds(); } }; Sounds.prototype.registerSources = function(listenerClip, arrSourceClips, id, maxAudibleRange) { var _loc2_ = {}; _loc2_.listener = listenerClip; _loc2_.sources = arrSourceClips; _loc2_.sound = this.sounds[id]; _loc2_.maxRange = maxAudibleRange; this.play(id,0,true); this.loops.push(_loc2_); return _loc2_.sources; }; Sounds.prototype.removeAllSources = function() { var _loc2_ = 0; while(_loc2_ < this.loops.length) { var _loc3_ = this.loops[_loc2_]; _loc3_.sound.stop(); _loc2_ = _loc2_ + 1; } this.loops = []; }; Sounds.prototype.evtEnterFrame = function() { var _loc10_ = 0; while(_loc10_ < this.loops.length) { var _loc3_ = this.loops[_loc10_]; var _loc7_ = _loc3_.maxRange; var _loc8_ = _loc3_.listener.holderToGlobal(); var _loc2_ = 0; while(_loc2_ < _loc3_.sources.length) { var _loc4_ = _loc3_.sources[_loc2_]; if(_loc4_ == undefined || _loc4_.notSoundSource == true) { _loc3_.sources.splice(_loc2_,1); _loc2_ = _loc2_ - 1; } else { var _loc5_ = _loc4_.holderToGlobal(); var _loc6_ = Maths.distance(_loc8_.x,_loc8_.y,_loc5_.x,_loc5_.y); if(_loc6_ < _loc7_) { _loc7_ = _loc6_; } } _loc2_ = _loc2_ + 1; } _loc3_.sound.setVolume(Math.floor(100 * (_loc3_.maxRange - _loc7_) / _loc3_.maxRange)); _loc10_ = _loc10_ + 1; } for(id in this.sounds) { if(this.sounds[id].targetVol != undefined) { var _loc9_ = this.sounds[id].getVolume(); var _loc11_ = _loc9_ - this.sounds[id].targetVol; if(Math.abs(_loc11_) < this.sounds[id].dVol) { this.sounds[id].setVolume(this.sounds[id].targetVol); this.sounds[id].targetVol = undefined; } else { this.sounds[id].setVolume(_loc11_ <= 0 ? _loc9_ + this.sounds[id].dVol : _loc9_ - this.sounds[id].dVol); } } } }; Physics.prototype.step = function() { if(this.paused == true) { return undefined; } var _loc14_ = 0; while(_loc14_ < this.masses.length) { var _loc13_ = this.masses[_loc14_]; _loc13_.hasHitSurface = false; if(!_loc13_.fixed) { _loc13_.prevX = _loc13_.x; _loc13_.prevY = _loc13_.y; var _loc6_ = _loc13_.sumSpringForces(); _loc6_.x += this.gravityX * _loc13_.mass; _loc6_.y += this.gravityY * _loc13_.mass; _loc6_.x += _loc13_.extForceX; _loc6_.y += _loc13_.extForceY; _loc13_.extForceX = 0; _loc13_.extForceY = 0; _loc13_.vx += _loc6_.x / _loc13_.mass; _loc13_.vy += _loc6_.y / _loc13_.mass; } _loc14_ = _loc14_ + 1; } if(this.attractingMasses) { _loc14_ = 0; while(_loc14_ < this.masses.length) { _loc13_ = this.masses[_loc14_]; if(_loc13_.attractionMass != 0) { _loc13_.applyAttractionForces(); } _loc14_ = _loc14_ + 1; } } _loc14_ = 0; while(_loc14_ < this.masses.length) { _loc13_ = this.masses[_loc14_]; if(!_loc13_.fixed) { if(_loc13_.vx > _loc13_.friction) { _loc13_.vx -= _loc13_.friction; } else if(_loc13_.vx < - _loc13_.friction) { _loc13_.vx += _loc13_.friction; } else { _loc13_.vx = 0; } if(_loc13_.vy > _loc13_.friction) { _loc13_.vy -= _loc13_.friction; } else if(_loc13_.vy < - _loc13_.friction) { _loc13_.vy += _loc13_.friction; } else { _loc13_.vy = 0; } _loc13_.vx *= this.drag; _loc13_.vy *= this.drag; } _loc14_ = _loc14_ + 1; } _loc14_ = 0; while(_loc14_ < this.masses.length) { _loc13_ = this.masses[_loc14_]; _loc13_.x += _loc13_.vx; _loc13_.y += _loc13_.vy; _loc14_ = _loc14_ + 1; } this.masses.sort(massSort,Array.NUMERIC); _loc14_ = 0; while(_loc14_ < this.masses.length) { this.masses[_loc14_].testedSet = []; _loc14_ = _loc14_ + 1; } var _loc7_ = []; if(this.collidableMasses) { _loc14_ = 0; while(_loc14_ < this.masses.length) { var _loc9_ = this.masses[_loc14_]; var _loc16_ = this.biggestMassRadius + _loc9_.radius + 1; var _loc15_ = _loc9_.x + _loc16_; var _loc2_ = _loc14_ + 1; while(_loc2_ < this.masses.length) { var _loc8_ = this.masses[_loc2_]; if(_loc8_.x > _loc15_) { _loc2_ = this.masses.length; } else if(_loc9_ != undefined && _loc8_ != undefined && _loc9_.testedSet[_loc2_] == undefined && _loc9_.collisionSet != undefined && _loc8_.collisionSet != undefined && _loc9_.collisionSet != _loc8_.collisionSet) { var _loc5_ = _loc9_.x - _loc8_.x; var _loc4_ = _loc9_.y - _loc8_.y; var _loc12_ = _loc5_ * _loc5_ + _loc4_ * _loc4_; var _loc10_ = (_loc9_.radius + _loc8_.radius) * (_loc9_.radius + _loc8_.radius); if(_loc12_ < _loc10_) { _loc7_.push({massA:_loc9_,massB:_loc8_}); } _loc9_.testedSet[_loc2_] = true; _loc8_.testedSet[_loc14_] = true; } _loc2_ = _loc2_ + 1; } _loc15_ = _loc9_.x - _loc16_; _loc2_ = _loc14_ - 1; while(_loc2_ >= 0) { _loc8_ = this.masses[_loc2_]; if(_loc8_.x < _loc15_) { _loc2_ = -1; } else if(_loc9_ != undefined && _loc8_ != undefined && _loc9_.testedSet[_loc2_] == undefined && _loc9_.collisionSet != undefined && _loc8_.collisionSet != undefined && _loc9_.collisionSet != _loc8_.collisionSet) { _loc5_ = _loc9_.x - _loc8_.x; _loc4_ = _loc9_.y - _loc8_.y; _loc12_ = _loc5_ * _loc5_ + _loc4_ * _loc4_; _loc10_ = _loc9_.radiusSquared + _loc8_.radiusSquared; if(_loc12_ < _loc10_) { _loc7_.push({massA:_loc9_,massB:_loc8_}); } _loc9_.testedSet[_loc2_] = true; _loc8_.testedSet[_loc14_] = true; } _loc2_ = _loc2_ - 1; } _loc14_ = _loc14_ + 1; } } _loc7_.sort(collisionSort); _loc14_ = 0; while(_loc14_ < _loc7_.length) { _loc7_[_loc14_].massA.resolveCollision(_loc7_[_loc14_].massB); _loc14_ = _loc14_ + 1; } _loc14_ = 0; while(_loc14_ < this.masses.length) { var _loc17_ = this.masses[_loc14_]; _loc2_ = 0; while(_loc2_ < this.surfaces.length) { var _loc11_ = this.surfaces[_loc2_]; _loc11_.handleCollision(_loc17_); _loc2_ = _loc2_ + 1; } _loc14_ = _loc14_ + 1; } if(this.framePaintCallback) { this.framePaintCallback(); } if(this.defaultPaint) { _loc14_ = 0; while(_loc14_ < this.masses.length) { _loc13_ = this.masses[_loc14_]; _loc13_.clip._x = _loc13_.x; _loc13_.clip._y = _loc13_.y; _loc14_ = _loc14_ + 1; } _loc14_ = 0; while(_loc14_ < this.springs.length) { var _loc3_ = this.springs[_loc14_]; _loc3_.clip.clear(); _loc3_.clip.lineStyle(1,16711680,100); _loc3_.clip.moveTo(_loc3_.mass1.x,_loc3_.mass1.y); _loc3_.clip.lineTo(_loc3_.mass2.x,_loc3_.mass2.y); _loc14_ = _loc14_ + 1; } } }; Mass.prototype.setRadius = function(r) { this.radius = r; this.radiusSquared = this.radius * this.radius; this.clip.clear(); this.clip.lineStyle(this.radius * 2,255,50); this.clip.moveTo(0,0); this.clip.lineTo(0,1); }; Mass.prototype.removeMass = function() { var _loc2_ = 0; while(_loc2_ < this.springs.length) { this.springs[_loc2_].removeSpring(); _loc2_ = _loc2_ - 1; _loc2_ = _loc2_ + 1; } _loc2_ = 0; while(_loc2_ < this.physics.masses.length) { if(this == this.physics.masses[_loc2_]) { this.physics.masses.splice(_loc2_,1); _loc2_ = this.physics.masses.length; } _loc2_ = _loc2_ + 1; } if(this.physics.defaultPaint) { this.clip.removeMovieClip(); } this.removed = true; }; Mass.prototype.sumSpringForces = function() { if(this.fixed) { return {x:0,y:0}; } var _loc5_ = {x:0,y:0}; var _loc3_ = 0; while(_loc3_ < this.springs.length) { var _loc2_ = undefined; var _loc4_ = this.springs[_loc3_]; if(this == _loc4_.mass1) { _loc2_ = _loc4_.forceOnMass1(); } else { _loc2_ = _loc4_.forceOnMass2(); } _loc5_.x += _loc2_.x; _loc5_.y += _loc2_.y; _loc3_ = _loc3_ + 1; } return _loc5_; }; Mass.prototype.applyAttractionForces = function() { var _loc3_ = 0; while(_loc3_ < this.physics.masses.length) { var _loc2_ = this.physics.masses[_loc3_]; if(_loc2_.attractionMass && this != _loc2_ && !_loc2_.fixed) { var _loc4_ = this.attractionForce(_loc2_); _loc2_.vx += _loc4_.x / _loc2_.mass; _loc2_.vy += _loc4_.y / _loc2_.mass; } _loc3_ = _loc3_ + 1; } }; Mass.prototype.attractionForce = function(otherMass) { var _loc5_ = this.x - otherMass.x; var _loc4_ = this.y - otherMass.y; var _loc3_ = Maths.vectorLength(_loc5_,_loc4_); _loc5_ /= _loc3_; _loc4_ /= _loc3_; var _loc2_ = this.attractionMass * this.physics.attractionScale / (_loc3_ * _loc3_); if(Math.abs(_loc2_) > this.attractionMaxForce) { _loc2_ = _loc2_ <= 0 ? - this.attractionMaxForce : this.attractionMaxForce; } return {x:_loc5_ * _loc2_,y:_loc4_ * _loc2_}; }; Mass.prototype.resolveCollision = function(otherMass) { if(this.collisionSet == undefined || this.collisionSet == otherMass.collisionSet) { return undefined; } if(otherMass == undefined) { return undefined; } var _loc9_ = Maths.distance(this.x,this.y,otherMass.x,otherMass.y); var _loc3_ = this.radius + otherMass.radius; if(_loc9_ < _loc3_) { var _loc5_ = (this.x + otherMass.x) / 2; var _loc4_ = (this.y + otherMass.y) / 2; var _loc7_ = this.x - _loc5_; var _loc6_ = this.y - _loc4_; var _loc8_ = Maths.vectorLength(_loc7_,_loc6_); _loc7_ /= _loc8_; _loc6_ /= _loc8_; if(!this.fixed && !otherMass.fixed) { this.x = _loc5_ + _loc7_ * _loc3_ / 2; this.y = _loc4_ + _loc6_ * _loc3_ / 2; otherMass.x = _loc5_ + _loc7_ * (- _loc3_) / 2; otherMass.y = _loc4_ + _loc6_ * (- _loc3_) / 2; } else { if(this.fixed && otherMass.fixed) { return undefined; } if(!this.fixed) { this.x = _loc5_ + _loc7_ * _loc3_ / 2; this.y = _loc4_ + _loc6_ * _loc3_ / 2; } if(!otherMass.fixed) { otherMass.x = _loc5_ + _loc7_ * (- _loc3_) / 2; otherMass.y = _loc4_ + _loc6_ * (- _loc3_) / 2; } } this.collisionX = _loc5_; this.collisionY = _loc4_; otherMass.collisionX = _loc5_; otherMass.collisionY = _loc4_; this.respondToCollision(otherMass); this.collisionCallback(otherMass); otherMass.collisionCallback(this); } }; Mass.prototype.respondToCollision = function(otherMass) { var _loc7_ = Math.atan2(this.y - otherMass.y,this.x - otherMass.x); var _loc4_ = Math.cos(_loc7_); var _loc3_ = Math.sin(_loc7_); var _loc6_ = this.vx * _loc4_ + this.vy * _loc3_; var _loc9_ = this.vy * _loc4_ - this.vx * _loc3_; var _loc5_ = otherMass.vx * _loc4_ + otherMass.vy * _loc3_; var _loc8_ = otherMass.vy * _loc4_ - otherMass.vx * _loc3_; var _loc12_ = this.mass * _loc6_ + otherMass.mass * _loc5_; var _loc13_ = _loc6_ - _loc5_; var _loc10_ = (_loc12_ + this.mass * _loc13_) / (this.mass + otherMass.mass); var _loc11_ = _loc10_ - _loc6_ + _loc5_; _loc6_ = _loc11_; _loc5_ = _loc10_; if(!this.fixed) { this.vx = _loc6_ * _loc4_ - _loc9_ * _loc3_; this.vy = _loc9_ * _loc4_ + _loc6_ * _loc3_; } if(!otherMass.fixed) { otherMass.vx = _loc5_ * _loc4_ - _loc8_ * _loc3_; otherMass.vy = _loc8_ * _loc4_ + _loc5_ * _loc3_; } }; Spring.prototype.removeSpring = function() { this.clip.removeMovieClip(); var _loc2_ = 0; while(_loc2_ < this.mass1.springs.length) { if(this == this.mass1.springs[_loc2_]) { this.mass1.springs.splice(_loc2_,1); break; } _loc2_ = _loc2_ + 1; } _loc2_ = 0; while(_loc2_ < this.mass2.springs.length) { if(this == this.mass2.springs[_loc2_]) { this.mass2.springs.splice(_loc2_,1); break; } _loc2_ = _loc2_ + 1; } _loc2_ = 0; while(_loc2_ < this.physics.springs.length) { if(this == this.physics.springs[_loc2_]) { this.physics.springs.splice(_loc2_,1); return undefined; } _loc2_ = _loc2_ + 1; } }; Spring.prototype.currentLength = function() { var _loc5_ = this.mass1.x; var _loc3_ = this.mass1.y; var _loc4_ = this.mass2.x; var _loc2_ = this.mass2.y; return Maths.distance(_loc5_,_loc3_,_loc4_,_loc2_); }; Spring.prototype.currentExtension = function() { return this.currentLength() - this.naturalLength; }; Spring.prototype.forceOnMass1 = function() { var _loc9_ = this.mass1.x; var _loc7_ = this.mass1.y; var _loc8_ = this.mass2.x; var _loc6_ = this.mass2.y; var _loc4_ = _loc8_ - _loc9_; var _loc3_ = _loc6_ - _loc7_; var _loc2_ = Maths.vectorLength(_loc4_,_loc3_); var _loc11_ = _loc4_ / _loc2_; var _loc10_ = _loc3_ / _loc2_; var _loc12_ = this.currentExtension() * this.k; var _loc14_ = this.mass2.vx - this.mass1.vx; var _loc13_ = this.mass2.vy - this.mass1.vy; var _loc15_ = this.damperK * Maths.dotProduct(_loc14_,_loc13_,_loc4_,_loc3_) / _loc2_; var _loc5_ = _loc15_ + _loc12_; return {x:_loc11_ * _loc5_,y:_loc10_ * _loc5_}; }; Spring.prototype.forceOnMass2 = function() { var _loc2_ = this.forceOnMass1(); return {x:- _loc2_.x,y:- _loc2_.y}; }; Surface.prototype.update = function() { this.len = this.currentLength(); this.x = this.x1; this.y = this.y1; this.dx = this.x2 - this.x1; this.dy = this.y2 - this.y1; this.nx = this.dx / this.len; this.ny = this.dy / this.len; this.normX = - this.ny; this.normY = this.nx; this.paint(); }; Surface.prototype.paint = function() { this.clip.clear(); this.clip.lineStyle(1,65535,100); this.clip.moveTo(this.x1,this.y1); this.clip.lineTo(this.x2,this.y2); }; Surface.prototype.currentLength = function() { return Maths.vectorLength(this.x1,this.y1,this.x2,this.y2); }; Surface.prototype.removeSurface = function() { this.clip.removeMovieClip(); var _loc2_ = 0; while(_loc2_ < this.physics.surfaces.length) { if(this == this.physics.surfaces[_loc2_]) { this.physics.surfaces.splice(_loc2_,1); return undefined; } _loc2_ = _loc2_ + 1; } }; Surface.prototype.handleCollision = function(objMass) { var _loc4_ = {}; _loc4_.dx = objMass.x - this.x1; _loc4_.dy = objMass.y - this.y1; var _loc13_ = Maths.dotProduct(_loc4_.dx,_loc4_.dy,this.dx,this.dy); var _loc2_ = {x:this.x1,y:this.y1,dx:_loc4_.dx,dy:_loc4_.dy}; if(_loc13_ >= 0) { var _loc5_ = {}; _loc5_.dx = objMass.x - this.x2; _loc5_.dy = objMass.y - this.y2; _loc13_ = Maths.dotProduct(_loc5_.dx,_loc5_.dy,this.dx,this.dy); _loc2_ = {x:this.x2,y:this.y2,dx:_loc5_.dx,dy:_loc5_.dy}; if(_loc13_ <= 0) { var _loc11_ = {dx:this.normX,dy:this.normY}; _loc2_ = Maths.vectorProject(_loc4_,_loc11_); _loc2_.x = objMass.x - _loc2_.dx; _loc2_.y = objMass.y - _loc2_.dy; } } var _loc8_ = Maths.vectorLength(_loc2_.dx,_loc2_.dy); var _loc7_ = objMass.radius - _loc8_; if(_loc7_ >= 0) { objMass.hasHitSurface = true; _loc2_.nx = _loc2_.dx / _loc8_; _loc2_.ny = _loc2_.dy / _loc8_; objMass.x += _loc7_ * _loc2_.nx; objMass.y += _loc7_ * _loc2_.ny; var _loc12_ = {dx:_loc2_.dy,dy:- _loc2_.dx}; var _loc10_ = {dx:objMass.vx,dy:objMass.vy}; var _loc6_ = Maths.vectorProject(_loc10_,_loc2_); var _loc9_ = Maths.vectorProject(_loc10_,_loc12_); objMass.collisionNormal = {x:_loc6_.dx,y:_loc6_.dy}; objMass.vx = (- this.restitution) * _loc6_.dx + this.friction * _loc9_.dx; objMass.vy = (- this.restitution) * _loc6_.dy + this.friction * _loc9_.dy; } return false; }; SpringBox.prototype.getPosition = function() { pos = {x:0,y:0,rRad:0,rDeg:0}; pos.x = (this.m_tl.x + this.m_tr.x + this.m_bl.x + this.m_br.x) / 4; pos.y = (this.m_tl.y + this.m_tr.y + this.m_bl.y + this.m_br.y) / 4; var _loc3_ = (this.frontLeft.x + this.frontRight.x) / 2; var _loc2_ = (this.frontLeft.y + this.frontRight.y) / 2; var _loc5_ = _loc3_ - pos.x; var _loc4_ = _loc2_ - pos.y; pos.rRad = Math.atan2(_loc4_,_loc5_); pos.rDeg = Maths.radToDeg(pos.rRad); return pos; }; SpringLine.prototype.getPosition = function() { pos = {x:0,y:0,rRad:0,rDeg:0}; pos.x = (this.m_b.x + this.m_f.x) / 2; pos.y = (this.m_b.y + this.m_f.y) / 2; var _loc3_ = this.m_f.x; var _loc2_ = this.m_f.y; var _loc5_ = _loc3_ - pos.x; var _loc4_ = _loc2_ - pos.y; pos.rRad = Math.atan2(_loc4_,_loc5_); pos.rDeg = Maths.radToDeg(pos.rRad); return pos; }; var arrNeverPress = ["Never press","Never press again","What? You were told not to press that","Seriously, stop pressing this button","Do you ever do what you\'re told?","Are you even reading these?","Are you even reading these?","Are you even reading these?","Oooh, persistent. STOP PRESSING!","That\'s it, one more press. The button dares you","Yup, the game just got made harder for you","Yep, really. You brought it on yourself","You only have yourself to blame","Seriously! It\'s like 4x harder now","Ok, so nothing\'s really changed","Except you\'re still clicking this button","You\'re not meant to be clicking this button","You know that, right?","You remember how this started?","You were told to never press","And yet you\'re still pressing","Endlessly pressing","You have no idea why you\'re still pressing","No clue at all, right?","Ok, time to stop pressing now","Really! Stop pressing","Stopit stopit stopit","STOPIT STOPIT STOPIT","AAAAGH! Stop pressing now!","Pleease stop pressing.","Right, no more begging.","Threats.","Nasty threats.","Keep pressing and I wipe your game progress","I mean it. Five more and bye-bye progress!","Four more...","Three...","Two","One more click and you lose your progress","Ha! It\'s gone. GONE! Gone for good","And your new progress won\'t be saved either","I\'ve deleted that part of the program","And yet you\'re still clicking","Endlessly clicking","Click click click click click...","New rules for clicking","From now on, each click earns you...","One file deleted at random from your hard drive!","Pop! There goes a file","Ping! And another","Was C:\\Windows\\win.ini important to you?","Another file deleted","Who needs all these files anyway?","You have thousands of \'em hanging around!","It\'s about time you had a clear up anyway","I\'m just helping you on your way","If I don\'t do it, someone else will","Maybe I\'m randomly deleting just the viruses","Or maybe your system files","I can\'t tell","But you\'re clicking lots and lots","Which means lots and lots of lost files","This is a clear case of escalation","You start annoying someone","Then keep pressing the buttons","Sooner or later they\'re getting revenge","By deleting all your files","You seem strangely unattached to your files","You do know what a file is, right?","They\'re the things on your computer","They make it function","They\'re your documents","They\'re your games","Your pictures","Everything on your computer lives in a file","And I\'m deleting one every time you click","...","...","...","Ok, so actually this is just a bit of a laugh","Nothing\'s really been changed by your clicking","No deleted files","Your game progress hasn\'t been wiped","The difficulty hasn\'t been cranked up","But it really is time to stop clicking","You see, it\'s inevitable","This button doesn\'t wear out","It can be clicked forever","But you. You!","You will get tired","You will need sleep","The button shall prevail","Long-live the button!","Short-live the human","Those fingers look soft","Like they\'d wear down over a few millenia","And you\'ve got to eat, right?","Have you set up a robot to press the button?","That\'d be cheating","The button would hate you for that","The button would be mad at you","And the button would cry","Do you want to make the button cry?","Do you?","DO YOU?","You\'re so mean.","*sniff*"]; ChoppaGame.prototype.initialise = function() { _root.trackPoint("Level_" + _root.curLevelID + "_start"); this.clip.level.gotoAndStop(_root.curLevelID); this.frame = 0; this.w = 730; this.h = 540; this.standardIdle = 0.3; this.standardThrottle = 1.2; this.winchIdle = 0.3; this.winchThrottle = 1.2; this.usedWinch = false; this.state = "flight"; this.winchState = "idle"; this.idleLift = this.standardIdle; this.throttleLift = this.standardThrottle; this.throttleLiftLow = this.standardThrottle * 0.6; this.torque = 0.04; this.perfect = true; this.bladeFrames = 10; this.controls = _root.controls; this.torqueAdjust = 1; switch(_root.sensitivity) { case "feather": this.torqueAdjust = 1; break; case "normal": this.torqueAdjust = 0.7; break; case "heavy": this.torqueAdjust = 0.4; } this.prevMouseX = _root._xmouse; this.prevMouseY = _root._ymouse; var _loc25_ = false; var _loc26_ = this.paint; this.gravity = 0.2; this.objPhysics = new Physics(this.clip.level.physics,0,this.gravity,0.99,true,false,_loc26_,_loc25_); addSurfaces(this.clip.level,"s",this.objPhysics,0.7,0.9); var _loc17_ = 0; var clip = this.clip.level["b" + _loc17_]; while(clip != undefined) { if(clip.oneton) { clip.item = "oneton"; var _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); var _loc5_ = new SpringBox(_loc9_.x,_loc9_.y,40,40,0,0,20,0.7,1.2,_loc17_,this.objPhysics); clip.objBox = _loc5_; _loc5_.m_tl.oneton = true; _loc5_.m_tr.oneton = true; _loc5_.m_bl.oneton = true; _loc5_.m_br.oneton = true; _loc5_.m_tl.collisionSound = "clunk"; _loc5_.m_tr.collisionSound = "clunk"; _loc5_.m_bl.collisionSound = "clunk"; _loc5_.m_br.collisionSound = "clunk"; } if(clip.magnet) { clip.item = "magnet"; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); var _loc3_ = new SpringLine(_loc9_.x,_loc9_.y,30,0,0,0,18,0.8,1,this.objPhysics,_loc17_); clip.objLine = _loc3_; this.objPhysics.attractingMasses = true; _loc3_.m_f.attractionMass = 25; _loc3_.m_f.collisionSound = "clink3"; _loc3_.m_b.collisionSound = "clink3"; } if(clip.scissors) { clip.item = "scissors"; var _loc19_ = clip.f.holderToLocal(this.objPhysics.baseClip); var _loc16_ = clip.b.holderToLocal(this.objPhysics.baseClip); clip.m_f = new Mass(_loc19_.x,_loc16_.y,21,false,this.objPhysics,_loc17_); clip.m_b = new Mass(_loc16_.x,_loc16_.y,34,false,this.objPhysics,_loc17_); clip.objLine = makeSpringLine(clip.m_f,clip.m_b); clip.m_f.isScissorHandle = true; clip.m_b.isScissorBlade = true; } if(clip.hair) { clip.item = "hair"; clip.cut = 0; this.clip.level.flag._y += 250; } if(clip.ball) { clip.item = "ball"; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); var _loc7_ = new Mass(_loc9_.x,_loc9_.y,19,false,this.objPhysics,_loc17_); _loc7_.mass = 1.5; _loc7_.clip = clip; clip.objMass = _loc7_; _loc7_.collisionSound = "clink"; } if(clip.sailor) { clip.item = "sailor"; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); _loc7_ = new Mass(_loc9_.x,_loc9_.y,31,false,this.objPhysics,_loc17_); _loc7_.mass = 1.2; _loc7_.isSailor = true; _loc7_.clip = clip; clip.objMass = _loc7_; } if(clip.hitchecker) { clip.item = "hitchecker"; } if(clip.boat) { clip.item = "boat"; this.clip.level.flag._y += 1000; clip.p0._visible = false; clip.p1._visible = false; clip.p2._visible = false; clip.p3._visible = false; clip.p4._visible = false; clip.p5._visible = false; clip.p6._visible = false; var _loc8_ = clip.p0.holderToLocal(this.objPhysics.baseClip); _loc19_ = clip.p1.holderToLocal(this.objPhysics.baseClip); _loc16_ = clip.p2.holderToLocal(this.objPhysics.baseClip); var _loc15_ = clip.p3.holderToLocal(this.objPhysics.baseClip); var _loc14_ = clip.p4.holderToLocal(this.objPhysics.baseClip); var _loc13_ = clip.p5.holderToLocal(this.objPhysics.baseClip); var _loc12_ = clip.p6.holderToLocal(this.objPhysics.baseClip); clip.m0 = new Mass(_loc8_.x,_loc8_.y,25,false,this.objPhysics,_loc17_); clip.m1 = new Mass(_loc19_.x,_loc19_.y,25,false,this.objPhysics,_loc17_); clip.m2 = new Mass(_loc16_.x,_loc16_.y,25,false,this.objPhysics,_loc17_); clip.m3 = new Mass(_loc15_.x,_loc15_.y,25,false,this.objPhysics,_loc17_); clip.m4 = new Mass(_loc14_.x,_loc14_.y,25,false,this.objPhysics,_loc17_); clip.m5 = new Mass(_loc13_.x,_loc13_.y,25,false,this.objPhysics,_loc17_); clip.m6 = new Mass(_loc12_.x,_loc12_.y,25,false,this.objPhysics,_loc17_); clip.m0.mass = 1.2; clip.m1.mass = 1.2; clip.m2.mass = 1.2; clip.m3.mass = 1.2; clip.m4.mass = 1.2; clip.m5.mass = 1.2; clip.m6.mass = 1.2; clip.m0.isBoatFront = true; clip.m3.isBoatRear = true; clip.plaque = makeSpringLine(clip.m0,clip.m1); var _loc21_ = new Spring(clip.m1,clip.m2); _loc21_ = new Spring(clip.m2,clip.m3); _loc21_ = new Spring(clip.m3,clip.m4); _loc21_ = new Spring(clip.m4,clip.m5); _loc21_ = new Spring(clip.m5,clip.m6); _loc21_ = new Spring(clip.m6,clip.m0); _loc21_ = new Spring(clip.m6,clip.m1,0.1,0.3); _loc21_ = new Spring(clip.m1,clip.m5,0.1,0.3); _loc21_ = new Spring(clip.m5,clip.m2,0.1,0.3); _loc21_ = new Spring(clip.m2,clip.m4,0.1,0.3); } if(clip.sheep) { clip.item = "sheep"; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); _loc7_ = new Mass(_loc9_.x,_loc9_.y,25,false,this.objPhysics,_loc17_); _loc7_.mass = 1; _loc7_.isSheep = true; clip.objMass = _loc7_; clip.dir = Maths.randomNum(-0.3,0.3); clip.dirFrames = Maths.randomInt(30,100); _loc7_.collisionSound = "baa"; } if(clip.sheeppen) { clip.item = "sheeppen"; } if(clip.platform) { clip.item = "platform"; } if(clip.hover) { clip.item = "hover"; } if(clip.net) { clip.item = "net"; clip.state = "untriggered"; clip.masses = []; _loc8_ = clip.p0.holderToLocal(this.objPhysics.baseClip); _loc19_ = clip.p1.holderToLocal(this.objPhysics.baseClip); var _loc20_ = _loc19_.x - _loc8_.x; var _loc18_ = Math.floor(_loc20_ / 40); var _loc4_ = 0; while(_loc4_ < _loc18_) { var _loc6_ = new Mass(_loc8_.x + 40 * _loc4_,_loc8_.y,12,true,this.objPhysics,_loc4_ + 20); if(_loc4_ > 0) { _loc6_.netSpring = new Spring(_loc6_,clip.masses[_loc4_ - 1]); } clip.masses.push(_loc6_); _loc4_ = _loc4_ + 1; } } if(clip.bee) { clip.item = "bee"; if(this.arrBees == undefined) { this.arrBees = _root.objSounds.registerSources(this.clip.level.choppa,[],"bee-buzz",300); } this.arrBees.push(clip); this.deadBees = 0; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); clip.targetX = _loc9_.x; clip.targetY = _loc9_.y; clip.targetR = Maths.randomNum(0,6.283185307179586); clip.targetDR = Maths.randomNum(-0.05,-0.2); clip.targetRadius = Maths.randomNum(20,50); _loc7_ = new Mass(_loc9_.x,_loc9_.y,22,false,this.objPhysics,_loc17_); _loc7_.mass = 0.75; _loc7_.clip = clip; _loc7_.objGame = this; clip.objMass = _loc7_; _loc7_.collisionCallback = function(otherMass) { if(otherMass.oneton) { this.objGame.deadBees = this.objGame.deadBees + 1; if(this.objGame.deadBees == 6) { _root.achieved(2); } _root.objSounds.play("bee-squish"); this.clip.gotoAndPlay("death"); this.clip.notSoundSource = true; this.removeMass(); } }; } if(clip.gootower) { clip.item = "gootower"; this.makeGooTower(clip,5,100,0.1,0.2); } if(clip.stronggootower) { clip.item = "gootower"; this.makeGooTower(clip,7,78,0.5,0.5); } if(clip.sam) { this.hitBySam = false; clip.item = "sam"; clip.hit._visible = false; clip.rocketAway = false; clip.rocketID = _loc17_ + 1; } if(clip.rocket) { clip.item = "rocket"; clip._visible = false; clip.active = false; clip.samID = _loc17_ - 1; clip.samClip = this.clip.level["b" + clip.samID]; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); _loc3_ = new SpringLine(_loc9_.x,_loc9_.y,68,0,0,0,18,0.8,1,this.objPhysics,_loc17_); _loc3_.m_f.idleX = _loc3_.m_f.x; _loc3_.m_f.idleY = _loc3_.m_f.y; _loc3_.m_b.idleX = _loc3_.m_b.x; _loc3_.m_b.idleY = _loc3_.m_b.y; _loc3_.m_f.objGame = this; _loc3_.m_f.rocketClip = clip; _loc3_.m_f.isRocket = true; _loc3_.m_b.isRocket = true; _loc3_.m_f.isNotWinchable = true; _loc3_.m_b.isNotWinchable = true; clip.objLine = _loc3_; _loc3_.m_f.collisionSound = "clink1"; _loc3_.m_b.collisionSound = "clink1"; _loc3_.m_f.collisionCallback = function(otherMass) { if(otherMass.isChoppa) { _root.objSounds.play("sam-hit"); this.rocketClip.active = false; this.rocketClip._visible = false; this.rocketClip.samClip.rocketAway = false; this.objGame.createExplosion(this.x,this.y,20,500); this.objGame.hitBySam = true; } }; } if(clip.gravitywell) { clip.item = "gravitywell"; this.objPhysics.gravityX = 0; this.objPhysics.gravityY = 0; this.gravityCentreX = clip._x; this.gravityCentreY = clip._y; _loc4_ = 0; while(_loc4_ < 10) { clip["g" + _loc4_].gotoAndPlay(Maths.randomInt(1,clip["g" + _loc4_]._totalframes)); _loc4_ = _loc4_ + 1; } } if(clip.fan) { clip.item = "fan"; clip.hit._visible = false; if(this.arrFans == undefined) { this.arrFans = _root.objSounds.registerSources(this.clip.level.choppa,[],"wind-loop",270); } this.arrFans.push(clip.n0); this.arrFans.push(clip.n1); this.arrFans.push(clip.n2); } if(clip.mixer) { clip.item = "mixer"; clip.dr = 0.1; clip.surfaces = addSurfaces(clip,"s",this.objPhysics,0.9,0.95); } if(clip.crushotron) { clip.item = "crushotron"; clip.lSurfaces = addSurfaces(clip.l,"s",this.objPhysics,0.9,0.95); clip.rSurfaces = addSurfaces(clip.r,"s",this.objPhysics,0.9,0.95); } if(clip.button) { clip.item = "button"; clip.state = "off"; clip.hit._visible = false; } if(clip.lift) { clip.item = "lift"; clip.surfaces = addSurfaces(clip.lift,"s",this.objPhysics,0.9,0.95); _root.objSounds.registerSources(this.clip.level.choppa,[clip.lift],"ratchet-loop",700); } if(clip.handle) { clip.item = "handle"; _loc9_ = clip.holderToLocal(this.objPhysics.baseClip); var _loc11_ = clip.arm.handle.holderToLocal(this.objPhysics.baseClip); clip.prevAngle = clip.arm._rotation; clip.mHub = new Mass(_loc9_.x,_loc9_.y,10,true,this.objPhysics,_loc17_); clip.mHandle = new Mass(_loc11_.x,_loc11_.y,15,false,this.objPhysics,_loc17_); clip.sArm = new Spring(clip.mHub,clip.mHandle); clip.mHub.isNotWinchable = true; _root.objSounds.play("ratchet-loop",0,true); this.handleClip = clip; } if(clip.oven) { clip.item = "oven"; this.handleClip._y += 340; this.handleClip.mHub.y += 340; this.handleClip.mHandle.y += 340; this.handleClip._visible = false; this.clip.level.flag._y += 100; } if(clip.wave) { clip.item = "wave"; clip.gotoAndPlay(Maths.randomInt(1,clip._totalframes)); } _loc17_ = _loc17_ + 1; clip = this.clip.level["b" + _loc17_]; } var _loc24_ = this.clip.level.choppa.rotor.holderToLocal(this.clip); var _loc23_ = this.clip.level.choppa.tail.holderToLocal(this.clip); var _loc22_ = this.clip.level.choppa.cockpit.holderToLocal(this.clip); this.mRotor = new Mass(_loc24_.x,_loc24_.y,16,false,this.objPhysics,-1); this.mTail = new Mass(_loc23_.x,_loc23_.y,13,false,this.objPhysics,-1); this.mCockpit = new Mass(_loc22_.x,_loc22_.y,30,false,this.objPhysics,-1); this.mRotor.isChoppa = true; this.mTail.isChoppa = true; this.mCockpit.isChoppa = true; this.slChassis = makeSpringLine(this.mTail,this.mCockpit); this.slFront = makeSpringLine(this.mRotor,this.mCockpit); this.slBack = makeSpringLine(this.mRotor,this.mTail); _loc9_ = this.slFront.getPosition(); this.choppaRotationOffset = this.clip.level.choppa._rotation - _loc9_.rDeg; this.choppaBrokenFrames = 0; this.clip.gameHitZone._visible = false; this.clip.screenCentre._visible = false; this.clip.pausePanel._visible = false; this.clip.winPanel._visible = false; this.clip.crashPanel._visible = false; this.clip.perfectPanel._visible = false; this.clip.fastPanel._visible = false; this.clip.winPanel._alpha = 0; this.clip.crashPanel._alpha = 0; this.clip.perfectPanel._alpha = 0; this.clip.fastPanel._alpha = 0; if(!_root.arrLevels[_root.curLevelID].passed) { this.clip.perfectIndicator._alpha = 0; this.clip.fastIndicator._alpha = 0; } this.stars = []; _loc17_ = 0; while(_loc17_ < 15) { var _loc10_ = this.clip.level.bg.getNextHighestDepth(); this.clip.level.bg.attachMovie("star","star" + _loc10_,_loc10_); var clip = this.clip.level.bg["star" + _loc10_]; _loc9_ = {x:Maths.randomInt(0,this.w),y:Maths.randomInt(0,this.w)}; this.clip.level.bg.globalToLocal(_loc9_); clip._x = _loc9_.x; clip._y = _loc9_.y; clip._scale = Maths.randomNum(70,120); clip._rotation = Maths.randomInt(0,359); this.stars.push(clip); _loc17_ = _loc17_ + 1; } this.objPhysics.baseClip.onEnterFrame = undefined; this.clip.onEnterFrame = function() { this.objGame.evtEnterFrame(); }; Key.addListener(this); }; ChoppaGame.prototype.evtEnterFrame = function() { this.frame = this.frame + 1; var _loc4_ = 0; while(_loc4_ < this.stars.length) { var _loc3_ = this.stars[_loc4_]; var _loc22_ = _loc3_.holderToGlobal(); if(_loc22_.x < 0) { _loc3_._x += this.w; } if(_loc22_.y < 0) { _loc3_._y += this.h; } if(_loc22_.x > this.w) { _loc3_._x -= this.w; } if(_loc22_.y > this.h) { _loc3_._y -= this.h; } _loc4_ = _loc4_ + 1; } if(Key.isDown(Keys.Escape) && !_root.objTrans.transitioning) { _root.objSounds.play("rollover-tick"); Key.removeListener(this); _root.objTrans.goto("picklevel"); } if(Key.isDown(Keys.R) && !_root.objTrans.transitioning) { _root.objSounds.play("rollover-tick"); Key.removeListener(this); _root.objTrans.goto("restart"); } switch(this.state) { case "paused": this.frame = this.frame - 1; Mouse.show(); break; case "flight": if(this.controls == "full") { Mouse.hide(); } this.mRotor.extForceX = 0; this.mRotor.extForceY = 0; this.mCockpit.extForceX = 0; this.mCockpit.extForceY = 0; this.mTail.extForceX = 0; this.mTail.extForceY = 0; var _loc7_ = Math.cos(Maths.degToRad(this.clip.level.choppa._rotation - 90)); var _loc6_ = Math.sin(Maths.degToRad(this.clip.level.choppa._rotation - 90)); switch(this.controls) { case "easy": var _loc14_ = this.objPhysics.gravityX; var _loc13_ = this.objPhysics.gravityY; if(this.gravityCentreX != undefined) { _loc14_ = this.gravityCentreX - this.clip.level.choppa._x; _loc13_ = this.gravityCentreY - this.clip.level.choppa._y; } var _loc15_ = Maths.vectorLength(_loc14_,_loc13_); if(_loc15_ == 0) { _loc15_ = 1; } _loc14_ /= _loc15_; _loc13_ /= _loc15_; thrustX = _loc14_ * (- this.idleLift); thrustY = _loc13_ * (- this.idleLift); if(Key.isDown(Keys.CursorUp) || Key.isDown(Keys.W)) { thrustY -= this.throttleLift; } if(Key.isDown(Keys.CursorDown) || Key.isDown(Keys.S)) { thrustY += this.idleLift; } if(Key.isDown(Keys.CursorLeft) || Key.isDown(Keys.A)) { thrustX -= this.throttleLiftLow; } if(Key.isDown(Keys.CursorRight) || Key.isDown(Keys.D)) { thrustX += this.throttleLiftLow; } thrustX /= 3; thrustY /= 3; this.mRotor.extForceX += thrustX * 1.3; this.mRotor.extForceY += thrustY; this.mCockpit.extForceX += thrustX; this.mCockpit.extForceY += thrustY; this.mTail.extForceX += thrustX; this.mTail.extForceY += thrustY; var _loc12_ = 0; var _loc25_ = Maths.dotProduct(_loc14_,_loc13_,- _loc6_,_loc7_); _loc12_ += 5 * _loc25_; if(Key.isDown(Keys.Z) || Key.isDown(Keys.Y)) { _loc12_ += 5 + this.leftCount++ / 10; } else { this.leftCount = 0; } if(Key.isDown(Keys.X)) { _loc12_ -= 5 + this.rightCount++ / 10; } else { this.rightCount = 0; } this.mCockpit.extForceX += _loc7_ * _loc12_ * this.torque; this.mCockpit.extForceY += _loc6_ * _loc12_ * this.torque; this.mTail.extForceX -= _loc7_ * _loc12_ * this.torque; this.mTail.extForceY -= _loc6_ * _loc12_ * this.torque; break; case "full": var _loc10_ = this.idleLift; var torque = this.torque; if(Key.isDown(Keys.CursorUp) || Keys.mouseDown() || Key.isDown(Keys.W)) { _loc10_ = this.throttleLift; } _loc10_ /= 3; this.mRotor.extForceX += _loc10_ * _loc7_; this.mRotor.extForceY += _loc10_ * _loc6_; this.mCockpit.extForceX += _loc10_ * _loc7_; this.mCockpit.extForceY += _loc10_ * _loc6_; this.mTail.extForceX += _loc10_ * _loc7_; this.mTail.extForceY += _loc10_ * _loc6_; _loc12_ = this.prevMouseX - _root._xmouse; var _loc26_ = this.prevMouseY - _root._ymouse; if(Key.isDown(Keys.CursorLeft) || Key.isDown(Keys.A)) { _loc12_ += 5 + this.leftCount++ / 10; } else { this.leftCount = 0; } if(Key.isDown(Keys.CursorRight) || Key.isDown(Keys.D)) { _loc12_ -= 5 + this.rightCount++ / 10; } else { this.rightCount = 0; } this.mCockpit.extForceX += _loc7_ * _loc12_ * torque * this.torqueAdjust; this.mCockpit.extForceY += _loc6_ * _loc12_ * torque * this.torqueAdjust; this.mTail.extForceX -= _loc7_ * _loc12_ * torque * this.torqueAdjust; this.mTail.extForceY -= _loc6_ * _loc12_ * torque * this.torqueAdjust; } this.bladeFrames = this.bladeFrames - 1; if(this.bladeFrames <= 0) { this.bladeFrames = 6; if(Key.isDown(Keys.CursorUp) || Key.isDown(Keys.W) || Key.isDown(Keys.CursorDown) || Key.isDown(Keys.S) || Key.isDown(Keys.CursorLeft) || Key.isDown(Keys.A) || Key.isDown(Keys.CursorRight) || Key.isDown(Keys.D) || Keys.mouseDown()) { this.bladeFrames = 4; } _root.objSounds.play("blade"); } this.objectsEnterFrame(); this.objPhysics.step(); this.paint(); if(this.controls == "full" && !this.clip.gameHitZone.hitTest(_root._xmouse,_root._ymouse,true)) { this.state = "paused"; this.pauseObjects(); this.clip.pausePanel.fadeIn(0.25); this.clip.pausePanel.objGame = this; this.clip.pausePanel.onRelease = function() { _root.objSounds.play("rollover-tick"); this.objGame.unpauseObjects(); this.objGame.state = "flight"; this.fadeOut(0.25); this.onRelease = undefined; this.onRollOver = undefined; }; this.clip.pausePanel.onRollOver = function() { _root.objSounds.play("rollover-tock"); }; } var _loc9_ = 0; if(this.mCockpit.hasHitSurface) { var _loc21_ = Maths.vectorLength(this.mCockpit.collisionNormal.x,this.mCockpit.collisionNormal.y); if(_loc21_ > _loc9_) { _loc9_ = _loc21_; } } if(this.mTail.hasHitSurface) { _loc21_ = Maths.vectorLength(this.mTail.collisionNormal.x,this.mTail.collisionNormal.y); if(_loc21_ > _loc9_) { _loc9_ = _loc21_; } } if(this.mRotor.hasHitSurface) { _loc21_ = Maths.vectorLength(this.mRotor.collisionNormal.x,this.mRotor.collisionNormal.y); if(_loc21_ > _loc9_) { _loc9_ = _loc21_; } } var _loc17_ = false; var _loc18_ = {x:this.mCockpit.x,y:this.mCockpit.y}; var _loc20_ = {x:this.mRotor.x,y:this.mRotor.y}; var _loc19_ = {x:this.mTail.x,y:this.mTail.y}; this.clip.level.physics.localToGlobal(_loc18_); this.clip.level.physics.localToGlobal(_loc20_); this.clip.level.physics.localToGlobal(_loc19_); if(!this.clip.level.choppa.hitCockpit.hitTest(_loc18_.x,_loc18_.y,true)) { _loc17_ = true; } if(!this.clip.level.choppa.hitRotor.hitTest(_loc20_.x,_loc20_.y,true)) { _loc17_ = true; } if(!this.clip.level.choppa.hitTail.hitTest(_loc19_.x,_loc19_.y,true)) { _loc17_ = true; } if(_loc17_) { this.choppaBrokenFrames = this.choppaBrokenFrames + 1; } else { this.choppaBrokenFrames = 0; } if(this.perfect && _loc9_ > 0 && !this.clip.level.choppa.hitTest(this.clip.level.flag)) { this.perfect = false; this.clip.perfectIndicator.fadeOut(0.5); } if(this.frame == _root.arrLevels[_root.curLevelID].par) { this.clip.fastIndicator.fadeOut(0.5); } if(_loc9_ > 14 || this.choppaBrokenFrames > 20) { _root.trackPoint("Level_" + _root.curLevelID + "_crashed"); if(_root.curLevelID == 19) { this.pauseObjects(); } _root.objSounds.play("crashed"); this.state = "crashed"; this.clip.crashPanel.fadeIn(0.25); this.clip.crashPanel.objGame = this; this.clip.crashPanel.onRelease = function() { _root.objSounds.play("rollover-tick"); _root.objTrans.goto("picklevel"); Key.removeListener(this); this.onRelease = undefined; this.onRollOver = undefined; }; this.clip.crashPanel.onRollOver = function() { _root.objSounds.play("rollover-tock"); }; return undefined; } if(this.mCockpit.hasHitSurface && this.mTail.hasHitSurface && this.clip.level.choppa.hitTest(this.clip.level.flag)) { trace("Completed level " + _root.curLevelID + " in " + this.frame + " frames"); var _loc16_ = false; if(this.frame < _root.arrLevels[_root.curLevelID].par) { _loc16_ = true; } if(this.hitBySam == true) { _root.achieved(3); } if(_root.curLevelID == 14 && !this.usedWinch) { _root.achieved(4); } if(_root.curLevelID == 15) { var _loc24_ = this.gooTop1.holderToGlobal(); var _loc23_ = this.gooTop2.holderToGlobal(); if(this.clip.level.towerHit.hitTest(_loc24_.x,_loc24_.y,true) && this.clip.level.towerHit.hitTest(_loc23_.x,_loc23_.y,true)) { _root.achieved(5); } } if(_root.curLevelID == 20) { _loc24_ = this.gooTop1.holderToGlobal(); _loc23_ = this.gooTop2.holderToGlobal(); if(this.clip.level.towerHit.hitTest(_loc24_.x,_loc24_.y,true) && this.clip.level.towerHit.hitTest(_loc23_.x,_loc23_.y,true)) { _root.achieved(6); } } if(_root.curLevelID == 21) { _root.achieved(7); } if(this.perfect) { _root.trackPoint("Level_" + _root.curLevelID + "_perfect"); _root.objSounds.play("voice-perfect"); } else if(_loc16_) { _root.trackPoint("Level_" + _root.curLevelID + "_fast"); _root.objSounds.play("voice-reallyfast"); } else { _root.trackPoint("Level_" + _root.curLevelID + "_completed"); _root.objSounds.play("voice-complete"); } passedLevel(_root.curLevelID,this.perfect,_loc16_); var _loc11_ = 0; var _loc5_ = 0; var _loc8_ = 0; _loc4_ = 0; while(_loc4_ < _root.arrLevels.length) { if(_root.arrLevels[_loc4_].passed) { _loc11_ = _loc11_ + 1; } if(_root.arrLevels[_loc4_].perfect) { _loc5_ = _loc5_ + 1; } if(_root.arrLevels[_loc4_].fast) { _loc8_ = _loc8_ + 1; } _loc4_ = _loc4_ + 1; } if(_loc11_ >= 21) { _root.achieved(8); } if(_loc5_ >= 10) { _root.achieved(9); } if(_loc5_ >= 21) { _root.achieved(10); } if(_loc8_ >= 10) { _root.achieved(11); } if(_loc8_ >= 21) { _root.achieved(12); } this.state = "completed"; this.pauseObjects(); this.clip.winPanel.fadeIn(0.25); this.clip.winPanel.objGame = this; this.clip.winPanel.onRelease = function() { _root.objSounds.play("rollover-tick"); _root.objTrans.goto("picklevel"); Key.removeListener(this); this.onRelease = undefined; this.onRollOver = undefined; }; this.clip.winPanel.onRollOver = function() { _root.objSounds.play("rollover-tock"); }; if(this.perfect) { trace(" Perfect!"); this.clip.perfectPanel.fadeIn(1.5); } if(_loc16_) { trace(" Fast!"); this.clip.fastPanel.fadeIn(1.5); } } break; case "crashed": Mouse.show(); this.clip.level.choppa.stop(); this.objectsEnterFrame(); this.objPhysics.step(); this.paint(); if(Key.isDown(Keys.Enter)) { this.clip.crashPanel.onRelease(); } break; case "completed": if(Key.isDown(Keys.Enter)) { this.clip.winPanel.onRelease(); } Mouse.show(); break; default: trace("Undefined state: " + this.state); } this.prevMouseX = _root._xmouse; this.prevMouseY = _root._ymouse; _loc22_ = this.clip.level.choppa.holderToLocal(this.clip.screenCentre); this.clip.level._x -= _loc22_.x / 4; this.clip.level._y -= _loc22_.y / 4; }; ChoppaGame.prototype.objectsEnterFrame = function() { var _loc17_ = this.clip.level.choppa.winch.holderToLocal(this.clip.level.physics); this.mWinchA.x = _loc17_.x; this.mWinchA.y = _loc17_.y; var _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { var _loc7_ = this.objPhysics.masses[_loc8_]; if(_loc7_.soundFrames > 0) { _loc7_.soundFrames = _loc7_.soundFrames - 1; if(_loc7_.soundFrames <= 0) { _loc7_.soundFrames = undefined; } } if(_loc7_.collisionSound && _loc7_.hasHitSurface && _loc7_.soundFrames == undefined && (_loc7_.collisionNormal.x > 1 || _loc7_.collisionNormal.y > 1)) { var _loc24_ = Maths.vectorLength(_loc7_.collisionNormal.x,_loc7_.collisionNormal.y); _root.objSounds.play(_loc7_.collisionSound,Math.min(100,_loc24_ * 5)); _loc7_.soundFrames = 10; } _loc8_ = _loc8_ + 1; } var _loc26_ = 0; var clip = this.clip.level["b" + _loc26_]; while(clip != undefined) { switch(clip.item) { case "oneton": break; case "scissors": if(clip.m_b.springs.length == 2) { _loc17_ = clip.f.holderToGlobal(); _loc8_ = 0; var _loc3_ = this.clip.level["b" + _loc8_]; while(_loc3_ != undefined) { if(_loc3_.item == "hair") { if(_loc3_.cut < 4 && _loc3_.hitTest(_loc17_.x,_loc17_.y,true)) { _loc3_.cut = _loc3_.cut + 1; _loc3_.gotoAndStop("cut" + _loc3_.cut); if(_loc3_.cut >= 4) { this.clip.level.flag._y -= 250; } } } _loc8_ = _loc8_ + 1; _loc3_ = this.clip.level["b" + _loc8_]; } } break; case "fan": _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { var _loc9_ = Maths.distance(clip._x,clip._y,_loc7_.x,_loc7_.y); if(_loc9_ > clip.hit._width) { _loc9_ = clip.hit._width; } var _loc10_ = (clip.hit._width - _loc9_) / clip.hit._width; _loc7_.extForceX += _loc10_ * clip.fanStrength * Math.cos(Maths.degToRad(clip._rotation)); _loc7_.extForceY += _loc10_ * clip.fanStrength * Math.sin(Maths.degToRad(clip._rotation)); } _loc8_ = _loc8_ + 1; } break; case "wave": _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { _loc7_.extForceY -= this.gravity + 0.01 * _loc7_.radius; _loc7_.vx *= 0.95; _loc7_.vy *= 0.95; } _loc8_ = _loc8_ + 1; } break; case "hitchecker": _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hitTest(_loc17_.x,_loc17_.y,true)) { clip.massTouching(_loc7_); } _loc8_ = _loc8_ + 1; } break; case "button": if(clip.state == "off") { _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { _root.objSounds.play("switch"); clip.evtTriggered(); clip.state = "on"; clip.gotoAndStop("on"); } _loc8_ = _loc8_ + 1; } } break; case "ball": case "sailor": break; case "boat": if(this.menSaved && this.boatPositioned >= 2) { this.menSaved = false; this.clip.level.flag._y -= 1000; this.clip.level.flag._alpha = 0; this.clip.level.flag.fadeIn(0.5); this.clip.level.sign.gotoAndPlay("done"); } this.boatPositioned = 0; break; case "sheep": clip.dirFrames--; if(clip.dirFrames <= 0) { clip.dir = Maths.randomNum(-0.3,0.3); clip.dirFrames = Maths.randomInt(30,100); } if(clip.objMass.hasHitSurface) { clip.objMass.extForceX = clip.dir; } break; case "sheeppen": var _loc14_ = 0; _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; if(_loc7_.isSheep) { _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { _loc14_ = _loc14_ + 1; } } _loc8_ = _loc8_ + 1; } clip.sheepDeposited(_loc14_); break; case "platform": var _loc11_ = 0; _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { _loc7_ = this.objPhysics.masses[_loc8_]; if(_loc7_.isSailor) { _loc17_ = {x:_loc7_.x,y:_loc7_.y}; this.objPhysics.baseClip.localToGlobal(_loc17_); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { _loc11_ = _loc11_ + 1; } } _loc8_ = _loc8_ + 1; } clip.sailorsDeposited(_loc11_); break; case "hover": _loc17_ = this.clip.level.choppa.holderToGlobal(); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { clip.gotoAndStop("hover"); } else { clip.gotoAndStop("idle"); } break; case "net": if(clip.state == "untriggered") { _loc17_ = this.clip.level.choppa.holderToGlobal(); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { clip.state = "triggered"; _root.objSounds.play("net-fall"); var _loc6_ = 0; while(_loc6_ < clip.masses.length) { clip.masses[_loc6_].fixed = false; _loc6_ = _loc6_ + 1; } } } break; case "bee": clip.targetR += clip.targetDR; var _loc25_ = clip.targetX + clip.targetRadius * Math.cos(clip.targetR); var _loc22_ = clip.targetY + clip.targetRadius * Math.sin(clip.targetR); var _loc13_ = clip.objMass.x - _loc25_; var _loc12_ = clip.objMass.y - _loc22_; var _loc23_ = (- _loc13_) / 70; var _loc21_ = (- _loc12_) / 70; clip.objMass.extForceX += _loc23_; clip.objMass.extForceY += _loc21_; break; case "gravitywell": _loc8_ = 0; while(_loc8_ < this.objPhysics.masses.length) { var _loc5_ = this.objPhysics.masses[_loc8_]; _loc13_ = _loc5_.x - clip._x; _loc12_ = _loc5_.y - clip._y; var _loc15_ = Maths.vectorLength(_loc13_,_loc12_); _loc13_ /= _loc15_; _loc12_ /= _loc15_; _loc13_ *= this.gravity; _loc12_ *= this.gravity; _loc5_.extForceX -= _loc13_; _loc5_.extForceY -= _loc12_; _loc8_ = _loc8_ + 1; } break; case "mixer": if(this.mRotor.hasHitSurface || this.mTail.hasHitSurface || this.mCockpit.hasHitSurface) { clip.dr -= 0.005; } else { clip.dr += 0.005; } if(clip.dr < 0.1) { clip.dr = 0.1; } if(clip.dr > 0.5) { clip.dr = 0.5; } clip._rotation += clip.dr; _loc8_ = 0; while(_loc8_ < clip.surfaces.length) { clip.surfaces[_loc8_].removeSurface(); _loc8_ = _loc8_ + 1; } clip.surfaces = addSurfaces(clip,"s",this.objPhysics,0.9,0.95); break; case "crushotron": _loc8_ = 0; while(_loc8_ < clip.lSurfaces.length) { clip.lSurfaces[_loc8_].removeSurface(); _loc8_ = _loc8_ + 1; } _loc8_ = 0; while(_loc8_ < clip.rSurfaces.length) { clip.rSurfaces[_loc8_].removeSurface(); _loc8_ = _loc8_ + 1; } clip.lSurfaces = addSurfaces(clip.l,"s",this.objPhysics,0.9,0.95); clip.rSurfaces = addSurfaces(clip.r,"s",this.objPhysics,0.9,0.95); break; case "lift": _loc8_ = 0; while(_loc8_ < clip.surfaces.length) { clip.surfaces[_loc8_].removeSurface(); _loc8_ = _loc8_ + 1; } clip.surfaces = addSurfaces(clip.lift,"s",this.objPhysics,0.9,0.95); break; case "sam": if(!clip.rocketAway) { _loc17_ = this.clip.level.choppa.holderToGlobal(); if(clip.hit.hitTest(_loc17_.x,_loc17_.y,true)) { _root.objSounds.play("sam-launch"); var _loc4_ = this.clip.level["b" + clip.rocketID]; var _loc20_ = clip.sam.holderToLocal(this.clip.level.physics); var _loc16_ = clip.holderToLocal(this.clip.level.physics); _loc4_.objLine.m_f.x = _loc20_.x; _loc4_.objLine.m_f.y = _loc20_.y; _loc4_.objLine.m_b.x = _loc16_.x; _loc4_.objLine.m_b.y = _loc16_.y; _loc4_.objLine.m_f.vx = 0; _loc4_.objLine.m_f.vy = 0; _loc4_.objLine.m_b.vx = 0; _loc4_.objLine.m_b.vy = 0; _loc4_.active = true; _loc4_._visible = true; clip.rocketAway = true; } } break; case "rocket": if(clip.active) { clip.objLine.m_f.extForceY -= this.gravity; clip.objLine.m_b.extForceY -= this.gravity; _loc13_ = clip.objLine.m_f.x - clip.objLine.m_b.x; _loc12_ = clip.objLine.m_f.y - clip.objLine.m_b.y; _loc15_ = Maths.vectorLength(_loc13_,_loc12_); _loc13_ /= _loc15_; _loc12_ /= _loc15_; clip.objLine.m_f.extForceX += _loc13_ / 6; clip.objLine.m_f.extForceY += _loc12_ / 6; clip.objLine.m_b.extForceX += _loc13_ / 4; clip.objLine.m_b.extForceY += _loc12_ / 4; _loc13_ = clip.objLine.m_f.x - this.clip.level.choppa._x; _loc12_ = clip.objLine.m_f.y - this.clip.level.choppa._y; _loc15_ = Maths.vectorLength(_loc13_,_loc12_); _loc13_ /= _loc15_; _loc12_ /= _loc15_; clip.objLine.m_f.extForceX -= _loc13_ / 6; clip.objLine.m_f.extForceY -= _loc12_ / 6; } else { clip.objLine.m_f.x = clip.objLine.m_f.idleX; clip.objLine.m_f.y = clip.objLine.m_f.idleY; clip.objLine.m_b.x = clip.objLine.m_b.idleX; clip.objLine.m_b.y = clip.objLine.m_b.idleY; } } _loc26_ = _loc26_ + 1; clip = this.clip.level["b" + _loc26_]; } }; ChoppaGame.prototype.alignGravityMark = function(clip) { var _loc3_ = this.clip.level.choppa._x - this.clip.level.b0._x; var _loc2_ = this.clip.level.choppa._y - this.clip.level.b0._y; var _loc4_ = Math.atan2(_loc2_,_loc3_); var _loc5_ = Maths.radToDeg(_loc4_) + Maths.randomNum(-30,30); clip._rotation = _loc5_; }; ChoppaGame.prototype.paint = function() { this.clip.level.drawing.clear(); var p = this.slFront.getPosition(); this.clip.level.choppa._x = this.mRotor.x; this.clip.level.choppa._y = this.mRotor.y; this.clip.level.choppa._rotation = p.rDeg + this.choppaRotationOffset; var j = 0; var clip = this.clip.level["b" + j]; while(clip != undefined) { switch(clip.item) { case "oneton": var p = clip.objBox.getPosition(); clip._x = p.x; clip._y = p.y; clip._rotation = p.rDeg + 90; break; case "magnet": var p = clip.objLine.getPosition(); clip._x = p.x; clip._y = p.y; clip._rotation = p.rDeg + 180; break; case "scissors": var p = clip.objLine.getPosition(); clip._x = p.x; clip._y = p.y; clip._rotation = p.rDeg; if(clip.m_b.springs.length == 2) { clip.gotoAndStop("chopping"); } else { clip.gotoAndStop("stopped"); } break; case "ball": clip._x = clip.objMass.x; clip._y = clip.objMass.y; break; case "sailor": clip._x = clip.objMass.x; clip._y = clip.objMass.y; break; case "sheep": clip._x = clip.objMass.x; clip._y = clip.objMass.y; clip._xscale = clip.dir < 0 ? 100 : -100; break; case "bee": clip._x = clip.objMass.x; clip._y = clip.objMass.y; break; case "rocket": if(clip.active) { var p = clip.objLine.getPosition(); clip._x = p.x; clip._y = p.y; clip._rotation = p.rDeg; } break; case "net": this.clip.level.drawing.lineStyle(12,16737792,100); this.clip.level.drawing.moveTo(clip.masses[0].x,clip.masses[0].y); var n = 1; while(n < clip.masses.length) { this.clip.level.drawing.lineTo(clip.masses[n].x,clip.masses[n].y); n++; } break; case "gootower": var k = 0; while(k < clip.masses.length) { var mass = clip.masses[k]; mass.gooClip._x = mass.x; mass.gooClip._y = mass.y; var h = 0; while(h < mass.springs.length) { var m1 = mass.springs[h].mass1; var m2 = mass.springs[h].mass2; if(!(!m1.isGoo || !m2.isGoo)) { this.clip.level.drawing.lineStyle(9,16737792,100); this.clip.level.drawing.moveTo(m1.x,m1.y); this.clip.level.drawing.lineTo(m2.x,m2.y); } h++; } k++; } break; case "boat": this.clip.level.drawing.lineStyle(9,0,100); this.clip.level.drawing.beginFill(16737792,100); this.clip.level.drawing.moveTo(clip.m0.x,clip.m0.y); this.clip.level.drawing.lineTo(clip.m1.x,clip.m1.y); this.clip.level.drawing.lineTo(clip.m2.x,clip.m2.y); this.clip.level.drawing.lineTo(clip.m3.x,clip.m3.y); this.clip.level.drawing.lineTo(clip.m4.x,clip.m4.y); this.clip.level.drawing.lineTo(clip.m5.x,clip.m5.y); this.clip.level.drawing.lineTo(clip.m6.x,clip.m6.y); this.clip.level.drawing.lineTo(clip.m0.x,clip.m0.y); this.clip.level.drawing.endFill(); var p = clip.plaque.getPosition(); this.clip.level.hmsFragile._x = p.x; this.clip.level.hmsFragile._y = p.y; this.clip.level.hmsFragile._rotation = p.rDeg + 180; break; case "handle": var dx = clip.mHandle.x - clip.mHub.x; var dy = clip.mHandle.y - clip.mHub.y; var angleRad = Math.atan2(dy,dx) - 1.5707963267948966; var angleDeg = Maths.radToDeg(angleRad); clip.arm._rotation = angleDeg; clip.arm.handle._rotation = - angleDeg; var dr = clip.prevAngle - clip.arm._rotation; if(dr < -100) { dr = 0; } if(dr < -5) { dr = -5; } if(dr > 100) { dr = 0; } if(dr > 5) { dr = 5; } _root.objSounds.volume("ratchet-loop",Math.abs(20 * dr)); clip.angleChanged(dr); clip.prevAngle = clip.arm._rotation; break; case "oven": var k = 0; while(k < this.objPhysics.masses.length) { var mass = this.objPhysics.masses[k]; if(mass.clip.ingredient != undefined) { var p = {x:mass.x,y:mass.y}; this.clip.level.physics.localToGlobal(p); if(clip.hit.hitTest(p.x,p.y,true)) { clip.hit.evtItemHit(mass.clip); } } k++; } } j++; clip = this.clip.level["b" + j]; } if(this.winchState == "deployed") { var p = this.clip.level.choppa.winch.holderToLocal(this.clip.level.drawing); with(this.clip.level.drawing) { lineStyle(3,16737792,100); moveTo(p.x,p.y); lineTo(this.mWinchB.x,this.mWinchB.y); lineTo(this.mWinchC.x,this.mWinchC.y); lineTo(this.sWinchC.mass2.x,this.sWinchC.mass2.y); } if(this.sWinchC.mass2.removed) { this.toggleWinch(); } } }; ChoppaGame.prototype.createExplosion = function(x, y, force, forceRange) { var _loc11_ = this.clip.level.drawing.getNextHighestDepth(); this.clip.level.drawing.attachMovie("explosion","explosion" + _loc11_,_loc11_); var _loc12_ = this.clip.level.drawing["explosion" + _loc11_]; _loc12_._x = x; _loc12_._y = y; var _loc6_ = 0; while(_loc6_ < this.objPhysics.masses.length) { var _loc2_ = this.objPhysics.masses[_loc6_]; var _loc5_ = x - _loc2_.x; var _loc4_ = y - _loc2_.y; var _loc3_ = Maths.vectorLength(_loc5_,_loc4_); _loc5_ /= _loc3_; _loc4_ /= _loc3_; if(_loc3_ < forceRange) { _loc2_.vx -= force * _loc5_; _loc2_.vy -= force * _loc4_; } _loc6_ = _loc6_ + 1; } }; ChoppaGame.prototype.onKeyUp = function() { switch(Key.getCode()) { case 13: case 32: switch(this.state) { case "flight": this.toggleWinch(); break; case "completed": case "crashed": } } }; ChoppaGame.prototype.toggleWinch = function() { if(this.state != "flight") { return undefined; } switch(this.winchState) { case "idle": this.usedWinch = true; this.winchState = "deployed"; this.idleLift = this.winchIdle; this.throttleLift = this.winchThrottle; _root.objSounds.play("winch-deploy"); var _loc4_ = this.clip.level.choppa.winch.holderToLocal(this.clip.level.physics); var _loc3_ = this.clip.level.choppa.pulley.holderToLocal(this.clip.level.physics); this.mWinchA = new Mass(_loc4_.x,_loc4_.y,5,true,this.objPhysics,-1); this.mWinchB = new Mass(_loc3_.x,_loc3_.y,5,false,this.objPhysics,-1); this.mWinchC = new Mass(_loc4_.x,_loc4_.y,5,false,this.objPhysics,-1); this.mWinchD = new Mass(_loc3_.x,_loc3_.y,5,false,this.objPhysics,-1); this.sWinchA = new Spring(this.mWinchA,this.mWinchB,this.objPhysics,0.5,0.7); this.sWinchB = new Spring(this.mWinchB,this.mWinchC,this.objPhysics,0.5,0.7); this.sWinchC = new Spring(this.mWinchC,this.mWinchD,this.objPhysics,0.5,0.7); this.mWinchD.objGame = this; this.mWinchD.collisionCallback = function(otherMass) { if(otherMass.isNotWinchable) { return undefined; } if(otherMass.isSheep) { _root.objSounds.play("baa"); } _root.objSounds.play("winch-attach"); this.objGame.sWinchC.removeSpring(); this.objGame.sWinchC = new Spring(this.objGame.mWinchC,otherMass,this.objGame.objPhysics,0.5,0.7); this.removeMass(); }; break; case "deployed": this.winchState = "idle"; this.idleLift = this.standardIdle; this.throttleLift = this.standardThrottle; _root.objSounds.play("winch-retract"); this.mWinchD.removeMass(); this.mWinchC.removeMass(); this.mWinchB.removeMass(); this.mWinchA.removeMass(); } }; ChoppaGame.prototype.pauseObjects = function() { var _loc3_ = 0; var _loc2_ = this.clip.level["b" + _loc3_]; while(_loc2_ != undefined) { switch(_loc2_.item) { case "lift": case "wave": case "crushotron": _loc2_.stop(); break; } _loc3_ = _loc3_ + 1; _loc2_ = this.clip.level["b" + _loc3_]; } }; ChoppaGame.prototype.unpauseObjects = function() { var _loc3_ = 0; var _loc2_ = this.clip.level["b" + _loc3_]; while(_loc2_ != undefined) { switch(_loc2_.item) { case "lift": if(_loc2_._currentframe < _loc2_._totalframes) { _loc2_.play(); } break; case "wave": case "crushotron": _loc2_.play(); break; } _loc3_ = _loc3_ + 1; _loc2_ = this.clip.level["b" + _loc3_]; } }; ChoppaGame.prototype.raiseHandle = function() { this.handleClip._visible = true; this.handleClip.slideTo("0","-340",1.5,"easeInOutSine",0,function() { _root.objGame.handleClip.mHub.y -= 340; _root.objGame.handleClip.mHandle.y -= 340; } ); this.clip.level.b1.gotoAndStop("raise"); }; ChoppaGame.prototype.handleComplete = function() { this.clip.level.flag.slideTo("0","-100",1.5,"easeInOutSine"); }; ChoppaGame.prototype.makeGooTower = function(clip, stories, separation, k, d) { clip.masses = []; clip.b0._visible = false; clip.b1._visible = false; var _loc9_ = clip.b0.holderToLocal(this.clip.level.physics); var _loc8_ = clip.b1.holderToLocal(this.clip.level.physics); var _loc7_ = new Mass(_loc9_.x,_loc9_.y,19,true,this.objPhysics,-1); var _loc6_ = new Mass(_loc8_.x,_loc8_.y,19,true,this.objPhysics,-1); _loc7_.isGoo = true; _loc6_.isGoo = true; clip.masses.push(_loc7_); clip.masses.push(_loc6_); var _loc15_ = this.clip.level.physics.getNextHighestDepth(); var _loc5_ = 0; while(_loc5_ < stories) { _loc9_.y -= separation; _loc8_.y -= separation; var _loc3_ = new Mass(_loc9_.x,_loc9_.y,19,false,this.objPhysics,_loc15_); var _loc2_ = new Mass(_loc8_.x,_loc8_.y,19,false,this.objPhysics,_loc15_); _loc3_.mass = 2; _loc2_.mass = 2; _loc3_.isGoo = true; _loc2_.isGoo = true; _loc3_.collisionSound = "bee-squish"; _loc2_.collisionSound = "bee-squish"; var _loc4_ = this.clip.level.drawing.getNextHighestDepth(); this.clip.level.drawing.attachMovie("gooball","gooball" + _loc4_,_loc4_); var _loc14_ = this.clip.level.drawing["gooball" + _loc4_]; _loc4_ = this.clip.level.drawing.getNextHighestDepth(); this.clip.level.drawing.attachMovie("gooball","gooball" + _loc4_,_loc4_); var _loc13_ = this.clip.level.drawing["gooball" + _loc4_]; _loc3_.gooClip = _loc14_; _loc2_.gooClip = _loc13_; _loc3_.gooClip._x = _loc3_.x; _loc3_.gooClip._y = _loc3_.y; _loc2_.gooClip._x = _loc2_.x; _loc2_.gooClip._y = _loc2_.y; _loc3_.gooClip._rotation = Maths.randomInt(-20,20); _loc2_.gooClip._rotation = Maths.randomInt(-20,20); var _loc16_ = new Spring(_loc3_,_loc2_,this.objPhysics,k,d); _loc16_ = new Spring(_loc3_,_loc6_,this.objPhysics,k,d); _loc16_ = new Spring(_loc7_,_loc2_,this.objPhysics,k,d); _loc16_ = new Spring(_loc3_,_loc7_,this.objPhysics,0.6,0.4); _loc16_ = new Spring(_loc2_,_loc6_,this.objPhysics,0.6,0.4); clip.masses.push(_loc3_); clip.masses.push(_loc2_); _loc7_ = _loc3_; _loc6_ = _loc2_; _loc5_ = _loc5_ + 1; } this.gooTop1 = _loc7_.gooClip; this.gooTop2 = _loc6_.gooClip; }; ChoppaGame.prototype.evt = function() { }; _root.Datacap = function(formID, thirdPartySubmit) { this.formID = formID; this.thirdPartySubmit = thirdPartySubmit; this.controls = []; this.formInstance = undefined; this.sendingFrame = ""; this.successFrame = ""; this.failureFrame = ""; this.userID = 0; this.customIsValid = undefined; this.preSubmit = undefined; this.onSuccess = undefined; this.onFailure = undefined; this.datacapURL = "http://www.deeperbeige.com/datacap/datacap"; if(_level0.debug) { trace("Creating data form, ID=" + formID); } var _loc4_ = SharedObject.getLocal("cmuDatacap"); if(_loc4_.data.userID == undefined) { _loc4_.data.userID = Math.floor(Math.random() * 100000000) + 100000000; } this.userID = _loc4_.data.userID; _loc4_.flush(); this.registerTextbox = function(varName, instance, errorMarker) { if(_level0.debug) { trace("Registered textbox " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for textbox " + varName + ""); } this.controls.push({style:"textbox",varName:varName,instance:instance,errorMarker:errorMarker,isValid:this.validateTextbox,autoFill:this.autoFillTextbox}); instance.tabIndex = this.controls.length; instance.objForm = this; errorMarker._visible = false; }; this.validateTextbox = function(control) { if(control.errorMarker != undefined) { if(control.instance.text == undefined || control.instance.text == "") { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Invalid"); } control.errorMarker._visible = true; return false; } if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Valid"); } control.errorMarker._visible = false; return true; } return true; }; this.autoFillTextbox = function(control) { var _loc1_ = SharedObject.getLocal("cmuDatacap"); if(_loc1_.data[control.varName] != undefined) { control.instance.text = _loc1_.data[control.varName]; } }; this.registerEmailbox = function(varName, instance, errorMarker) { if(_level0.debug) { trace("Registered emailbox " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for emailbox " + varName + ""); } this.controls.push({style:"emailbox",varName:varName,instance:instance,errorMarker:errorMarker,isValid:this.validateEmailbox,autoFill:this.autoFillEmailbox}); instance.tabIndex = this.controls.length; instance.objForm = this; errorMarker._visible = false; }; this.validateEmailbox = function(control) { if(control.errorMarker != undefined) { var _loc3_ = true; if(control.instance.text == undefined) { _loc3_ = false; } if(control.instance.text == "") { _loc3_ = false; } var _loc5_ = control.instance.text.split("@"); if(_loc5_.length != 2) { _loc3_ = false; } if(_loc5_[0] == "") { _loc3_ = false; } var _loc2_ = _loc5_[1].split("."); if(_loc2_.length < 2) { _loc3_ = false; } var _loc1_ = 0; while(_loc1_ < _loc2_.length) { if(_loc2_[_loc1_] == "") { _loc3_ = false; } _loc1_ = _loc1_ + 1; } if(_loc3_) { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Invalid"); } control.errorMarker._visible = false; return true; } if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Valid"); } control.errorMarker._visible = true; return false; } return true; }; this.autoFillEmailbox = function(control) { var _loc1_ = SharedObject.getLocal("cmuDatacap"); if(_loc1_.data[control.varName] != undefined) { control.instance.text = _loc1_.data[control.varName]; } }; this.registerCheckbox = function(varName, instance, errorMarker) { if(_level0.debug) { trace("Registered checkbox " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for checkbox " + varName + ""); } this.controls.push({style:"checkbox",varName:varName,instance:instance,errorMarker:errorMarker,isValid:this.validateCheckbox,autoFill:this.autoFillCheckbox}); instance.tabIndex = this.controls.length; instance.objForm = this; errorMarker._visible = false; }; this.validateCheckbox = function(control) { if(control.errorMarker != undefined) { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName); } if(control.instance.selected != true) { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Invalid"); } control.errorMarker._visible = true; return false; } if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Valid"); } control.errorMarker._visible = false; return true; } return true; }; this.autoFillCheckbox = function(control) { var _loc1_ = SharedObject.getLocal("cmuDatacap"); if(_loc1_.data[control.varName] != undefined) { control.instance.selected = _loc1_.data[control.varName]; } }; this.registerRadioSet = function(varName, instance, errorMarker) { if(_level0.debug) { trace("Registered radioset " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for radioset " + varName + ""); } this.controls.push({style:"radioset",varName:varName,instance:instance,errorMarker:errorMarker,isValid:this.validateRadioSet,autoFill:this.autoFillRadioSet}); instance.tabIndex = this.controls.length; instance.objForm = this; errorMarker._visible = false; }; this.validateRadioSet = function(control) { if(control.errorMarker != undefined) { if(control.instance.selection == undefined) { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Invalid"); } control.errorMarker._visible = true; return false; } if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Valid"); } control.errorMarker._visible = false; return true; } return true; }; this.autoFillRadioSet = function(control) { return undefined; }; this.registerDropdown = function(varName, instance, errorMarker) { if(_level0.debug) { trace("Registered dropdown " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for dropdown " + varName + ""); } this.controls.push({style:"dropdown",varName:varName,instance:instance,errorMarker:errorMarker,isValid:this.validateDropdown,autoFill:this.autoFillDropdown}); instance.tabIndex = this.controls.length; instance.objForm = this; errorMarker._visible = false; }; this.validateDropdown = function(control) { if(control.errorMarker != undefined) { if(control.instance.selectedIndex == 0) { if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Invalid"); } control.errorMarker._visible = true; return false; } if(_level0.debug) { trace("Validating " + control.style + " " + control.varName + ": Valid"); } control.errorMarker._visible = false; return true; } return true; }; this.autoFillDropdown = function(control) { var _loc1_ = SharedObject.getLocal("cmuDatacap"); if(_loc1_.data[control.varName] != undefined) { control.instance.selectedIndex = _loc1_.data[control.varName]; } }; this.registerSubmit = function(varName, instance, value) { if(_level0.debug) { trace("Registered submit button " + varName + " errorMarker=" + errorMarker); } if(instance == undefined) { trace("Error: Instance not found for submit button " + varName + ""); } this.controls.push({style:"submit",varName:varName,instance:instance,value:value}); instance.objForm = this; instance.tabIndex = this.controls.length; instance.onRelease = this.submitForm; }; this.setHiddenValue = function(varName, value) { if(_level0.debug) { trace("Set hidden value " + varName + "=" + value); } var _loc3_ = undefined; var _loc2_ = 0; while(_loc2_ < this.controls.length) { if(this.controls[_loc2_].style == "hidden") { if(this.controls[_loc2_].varName == varName) { _loc3_ = _loc2_; } } _loc2_ = _loc2_ + 1; } if(_loc3_ == undefined) { this.controls.push({style:"hidden",varName:varName,value:value}); } else { this.controls[_loc3_].value = value; } }; this.registerFrames = function(sendingFrame, successFrame, failureFrame, formInstance) { if(_level0.debug) { trace("Registered frames for instance " + formInstance); } if(formInstance == undefined) { trace("Error: Registering frames, form instance invalid"); } this.formInstance = formInstance; this.sendingFrame = sendingFrame; this.successFrame = successFrame; this.failureFrame = failureFrame; }; this.registerCallbacks = function(customIsValid, preSubmit, onSuccess, onFailure) { if(_level0.debug) { trace("Registered callbacks"); } this.customIsValid = customIsValid; this.preSubmit = preSubmit; this.onSuccess = onSuccess; this.onFailure = onFailure; }; this.submitForm = function() { if(_level0.debug) { trace("Submit pressed - validating"); } var _loc6_ = true; if(this.objForm.customIsValid != undefined) { if(!this.objForm.customIsValid()) { _loc6_ = false; } } var _loc2_ = 0; while(_loc2_ < this.objForm.controls.length) { if(this.objForm.controls[_loc2_].isValid != undefined) { if(!this.objForm.controls[_loc2_].isValid(this.objForm.controls[_loc2_])) { _loc6_ = false; } } _loc2_ = _loc2_ + 1; } if(_loc6_) { if(_level0.debug) { trace("Form validated - sending"); } if(_level0.debug) { trace("Submitting form"); } var _loc5_ = new LoadVars(); var _loc7_ = new LoadVars(); _loc7_.objForm = this.objForm; this.objForm.preSubmit(); var _loc4_ = SharedObject.getLocal("cmuDatacap"); _loc2_ = 0; while(_loc2_ < this.objForm.controls.length) { var _loc3_ = ""; switch(this.objForm.controls[_loc2_].style) { case "textbox": _loc3_ = this.objForm.controls[_loc2_].instance.text; _loc4_.data[this.objForm.controls[_loc2_].varName] = _loc3_; break; case "emailbox": _loc3_ = this.objForm.controls[_loc2_].instance.text; _loc4_.data[this.objForm.controls[_loc2_].varName] = _loc3_; break; case "checkbox": _loc3_ = !this.objForm.controls[_loc2_].instance.selected ? false : true; _loc4_.data[this.objForm.controls[_loc2_].varName] = _loc3_; break; case "radioset": _loc3_ = this.objForm.controls[_loc2_].instance.selection.data; break; case "dropdown": _loc3_ = this.objForm.controls[_loc2_].instance.selectedItem.data; _loc4_.data[this.objForm.controls[_loc2_].varName] = this.objForm.controls[_loc2_].instance.selectedIndex; break; case "hidden": _loc3_ = this.objForm.controls[_loc2_].value; break; case "submit": _loc3_ = this.objForm.controls[_loc2_].value; this.objForm.controls[_loc2_].instance._visible = false; break; default: trace("Unhandled component style " + this.objForm.controls[_loc2_].style); } if(_level0.debug) { trace(" " + this.objForm.controls[_loc2_].varName + " = " + _loc3_); } _loc5_[this.objForm.controls[_loc2_].varName] = _loc3_; _loc2_ = _loc2_ + 1; } _loc4_.flush(); _loc5_.userID = this.objForm.userID; _loc5_.formID = this.objForm.formID; _loc7_.onLoad = function(success) { trace("SUCCESS: " + success); if(success) { if(_level0.debug) { trace("Success"); } this.objForm.onSuccess(); if(this.objForm.formInstance != undefined) { this.objForm.formInstance.gotoAndStop(this.objForm.successFrame); } } else { if(_level0.debug) { trace("Failed"); } this.objForm.onFailure(); if(this.objForm.formInstance != undefined) { this.objForm.formInstance.gotoAndStop(this.objForm.failureFrame); } } }; var _loc8_ = this.objForm.datacapURL + (this.objForm.thirdPartySubmit != undefined ? "_" + this.objForm.thirdPartySubmit : "") + ".php"; _loc5_.sendAndLoad(_loc8_,_loc7_,"POST"); if(this.objForm.formInstance != undefined) { this.objForm.formInstance.gotoAndStop(this.objForm.sendingFrame); } } else if(_level0.debug) { trace("Form data not validated"); } }; this.autoFill = function() { var _loc2_ = 0; while(_loc2_ < this.controls.length) { this.controls[_loc2_].autoFill(this.controls[_loc2_]); _loc2_ = _loc2_ + 1; } }; this.onKeyDown = function() { if(Key.isDown(16) && Key.isDown(17) && Key.isDown(192)) { this.autoFill(); } }; Key.addListener(this); trace("Press ctrl+shift+@ to autofill form with previously entered values"); this.initCountryDropDown = function(dropdownClip) { dropdownClip.addItem("Select Country","NIL"); dropdownClip.addItem("United Kingdom","GB"); dropdownClip.addItem("Ireland","IE"); dropdownClip.addItem("France","FR"); dropdownClip.addItem("Spain","ES"); dropdownClip.addItem("Netherlands","NL"); dropdownClip.addItem("Italy","IT"); dropdownClip.addItem("Germany","DE"); dropdownClip.addItem("United States","US"); dropdownClip.addItem("Canada","CA"); dropdownClip.addItem("---------------------","--"); dropdownClip.addItem("Afghanistan","AF"); dropdownClip.addItem("Albania","AL"); dropdownClip.addItem("Algeria","DZ"); dropdownClip.addItem("American Samoa","AS"); dropdownClip.addItem("Andorra","AD"); dropdownClip.addItem("Angola","AO"); dropdownClip.addItem("Anguilla","AI"); dropdownClip.addItem("Antarctica","AQ"); dropdownClip.addItem("Antigua And Barbuda","AG"); dropdownClip.addItem("Argentina","AR"); dropdownClip.addItem("Armenia","AM"); dropdownClip.addItem("Aruba","AW"); dropdownClip.addItem("Australia","AU"); dropdownClip.addItem("Austria","AT"); dropdownClip.addItem("Azerbaijan","AZ"); dropdownClip.addItem("Bahamas","BS"); dropdownClip.addItem("Bahrain","BH"); dropdownClip.addItem("Bangladesh","BD"); dropdownClip.addItem("Barbados","BB"); dropdownClip.addItem("Belarus","BY"); dropdownClip.addItem("Belgium","BE"); dropdownClip.addItem("Belize","BZ"); dropdownClip.addItem("Benin","BJ"); dropdownClip.addItem("Bermuda","BM"); dropdownClip.addItem("Bhutan","BT"); dropdownClip.addItem("Bolivia","BO"); dropdownClip.addItem("Bosnia And Herzegowina","BA"); dropdownClip.addItem("Botswana","BW"); dropdownClip.addItem("Bouvet Island","BV"); dropdownClip.addItem("Brazil","BR"); dropdownClip.addItem("British Indian Ocean Territory","IO"); dropdownClip.addItem("Brunei Darussalam","BN"); dropdownClip.addItem("Bulgaria","BG"); dropdownClip.addItem("Burkina Faso","BF"); dropdownClip.addItem("Burundi","BI"); dropdownClip.addItem("Cambodia","KH"); dropdownClip.addItem("Cameroon","CM"); dropdownClip.addItem("Cape Verde","CV"); dropdownClip.addItem("Cayman Islands","KY"); dropdownClip.addItem("Central African Republic","CF"); dropdownClip.addItem("Chad","TD"); dropdownClip.addItem("Chile","CL"); dropdownClip.addItem("China","CN"); dropdownClip.addItem("Christmas Island","CX"); dropdownClip.addItem("Cocos (Keeling) Islands","CC"); dropdownClip.addItem("Colombia","CO"); dropdownClip.addItem("Comoros","KM"); dropdownClip.addItem("Congo","CG"); dropdownClip.addItem("Cook Islands","CK"); dropdownClip.addItem("Costa Rica","CR"); dropdownClip.addItem("Cote D\'Ivoire","CI"); dropdownClip.addItem("Croatia (Local Name: Hrvatska)","HR"); dropdownClip.addItem("Cuba","CU"); dropdownClip.addItem("Cyprus","CY"); dropdownClip.addItem("Czech Republic","CZ"); dropdownClip.addItem("Denmark","DK"); dropdownClip.addItem("Djibouti","DJ"); dropdownClip.addItem("Dominica","DM"); dropdownClip.addItem("Dominican Republic","DO"); dropdownClip.addItem("East Timor","TP"); dropdownClip.addItem("Ecuador","EC"); dropdownClip.addItem("Egypt","EG"); dropdownClip.addItem("El Salvador","SV"); dropdownClip.addItem("Equatorial Guinea","GQ"); dropdownClip.addItem("Eritrea","ER"); dropdownClip.addItem("Estonia","EE"); dropdownClip.addItem("Ethiopia","ET"); dropdownClip.addItem("Falkland Islands (Malvinas)","FK"); dropdownClip.addItem("Faroe Islands","FO"); dropdownClip.addItem("Fiji","FJ"); dropdownClip.addItem("Finland","FI"); dropdownClip.addItem("French Guiana","GF"); dropdownClip.addItem("French Polynesia","PF"); dropdownClip.addItem("French Southern Territories","TF"); dropdownClip.addItem("Gabon","GA"); dropdownClip.addItem("Gambia","GM"); dropdownClip.addItem("Georgia","GE"); dropdownClip.addItem("Ghana","GH"); dropdownClip.addItem("Gibraltar","GI"); dropdownClip.addItem("Greece","GR"); dropdownClip.addItem("Greenland","GL"); dropdownClip.addItem("Grenada","GD"); dropdownClip.addItem("Guadeloupe","GP"); dropdownClip.addItem("Guam","GU"); dropdownClip.addItem("Guatemala","GT"); dropdownClip.addItem("Guinea","GN"); dropdownClip.addItem("Guinea-Bissau","GW"); dropdownClip.addItem("Guyana","GY"); dropdownClip.addItem("Haiti","HT"); dropdownClip.addItem("Heard And Mc Donald Islands","HM"); dropdownClip.addItem("Holy See (Vatican City State)","VA"); dropdownClip.addItem("Honduras","HN"); dropdownClip.addItem("Hong Kong","HK"); dropdownClip.addItem("Hungary","HU"); dropdownClip.addItem("Icel And","IS"); dropdownClip.addItem("India","IN"); dropdownClip.addItem("Indonesia","ID"); dropdownClip.addItem("Iran (Islamic Republic Of)","IR"); dropdownClip.addItem("Iraq","IQ"); dropdownClip.addItem("Israel","IL"); dropdownClip.addItem("Jamaica","JM"); dropdownClip.addItem("Japan","JP"); dropdownClip.addItem("Jordan","JO"); dropdownClip.addItem("Kazakhstan","KZ"); dropdownClip.addItem("Kenya","KE"); dropdownClip.addItem("Kiribati","KI"); dropdownClip.addItem("Korea, Dem People\'S Republic","KP"); dropdownClip.addItem("Korea, Republic Of","KR"); dropdownClip.addItem("Kuwait","KW"); dropdownClip.addItem("Kyrgyzstan","KG"); dropdownClip.addItem("Lao People\'S Dem Republic","LA"); dropdownClip.addItem("Latvia","LV"); dropdownClip.addItem("Lebanon","LB"); dropdownClip.addItem("Lesotho","LS"); dropdownClip.addItem("Liberia","LR"); dropdownClip.addItem("Libyan Arab Jamahiriya","LY"); dropdownClip.addItem("Liechtenstein","LI"); dropdownClip.addItem("Lithuania","LT"); dropdownClip.addItem("Luxembourg","LU"); dropdownClip.addItem("Macau","MO"); dropdownClip.addItem("Macedonia","MK"); dropdownClip.addItem("Madagascar","MG"); dropdownClip.addItem("Malawi","MW"); dropdownClip.addItem("Malaysia","MY"); dropdownClip.addItem("Maldives","MV"); dropdownClip.addItem("Mali","ML"); dropdownClip.addItem("Malta","MT"); dropdownClip.addItem("Marshall Islands","MH"); dropdownClip.addItem("Martinique","MQ"); dropdownClip.addItem("Mauritania","MR"); dropdownClip.addItem("Mauritius","MU"); dropdownClip.addItem("Mayotte","YT"); dropdownClip.addItem("Mexico","MX"); dropdownClip.addItem("Micronesia, Federated States","FM"); dropdownClip.addItem("Moldova, Republic Of","MD"); dropdownClip.addItem("Monaco","MC"); dropdownClip.addItem("Mongolia","MN"); dropdownClip.addItem("Montserrat","MS"); dropdownClip.addItem("Morocco","MA"); dropdownClip.addItem("Mozambique","MZ"); dropdownClip.addItem("Myanmar","MM"); dropdownClip.addItem("Namibia","NA"); dropdownClip.addItem("Nauru","NR"); dropdownClip.addItem("Nepal","NP"); dropdownClip.addItem("Netherlands Ant Illes","AN"); dropdownClip.addItem("New Caledonia","NC"); dropdownClip.addItem("New Zealand","NZ"); dropdownClip.addItem("Nicaragua","NI"); dropdownClip.addItem("Niger","NE"); dropdownClip.addItem("Nigeria","NG"); dropdownClip.addItem("Niue","NU"); dropdownClip.addItem("Norfolk Island","NF"); dropdownClip.addItem("Northern Mariana Islands","MP"); dropdownClip.addItem("Norway","NO"); dropdownClip.addItem("Oman","OM"); dropdownClip.addItem("Pakistan","PK"); dropdownClip.addItem("Palau","PW"); dropdownClip.addItem("Panama","PA"); dropdownClip.addItem("Papua New Guinea","PG"); dropdownClip.addItem("Paraguay","PY"); dropdownClip.addItem("Peru","PE"); dropdownClip.addItem("Philippines","PH"); dropdownClip.addItem("Pitcairn","PN"); dropdownClip.addItem("Poland","PL"); dropdownClip.addItem("Portugal","PT"); dropdownClip.addItem("Puerto Rico","PR"); dropdownClip.addItem("Qatar","QA"); dropdownClip.addItem("Reunion","RE"); dropdownClip.addItem("Romania","RO"); dropdownClip.addItem("Russian Federation","RU"); dropdownClip.addItem("Rwanda","RW"); dropdownClip.addItem("Saint K Itts And Nevis","KN"); dropdownClip.addItem("Saint Lucia","LC"); dropdownClip.addItem("Saint Vincent, The Grenadines","VC"); dropdownClip.addItem("Samoa","WS"); dropdownClip.addItem("San Marino","SM"); dropdownClip.addItem("Sao Tome And Principe","ST"); dropdownClip.addItem("Saudi Arabia","SA"); dropdownClip.addItem("Senegal","SN"); dropdownClip.addItem("Seychelles","SC"); dropdownClip.addItem("Sierra Leone","SL"); dropdownClip.addItem("Singapore","SG"); dropdownClip.addItem("Slovakia (Slovak Republic)","SK"); dropdownClip.addItem("Slovenia","SI"); dropdownClip.addItem("Solomon Islands","SB"); dropdownClip.addItem("Somalia","SO"); dropdownClip.addItem("South Africa","ZA"); dropdownClip.addItem("South Georgia , S Sandwich Is.","GS"); dropdownClip.addItem("Sri Lanka","LK"); dropdownClip.addItem("St. Helena","SH"); dropdownClip.addItem("St. Pierre And Miquelon","PM"); dropdownClip.addItem("Sudan","SD"); dropdownClip.addItem("Suriname","SR"); dropdownClip.addItem("Svalbard, Jan Mayen Islands","SJ"); dropdownClip.addItem("Sw Aziland","SZ"); dropdownClip.addItem("Sweden","SE"); dropdownClip.addItem("Switzerland","CH"); dropdownClip.addItem("Syrian Arab Republic","SY"); dropdownClip.addItem("Taiwan","TW"); dropdownClip.addItem("Tajikistan","TJ"); dropdownClip.addItem("Tanzania, United Republic Of","TZ"); dropdownClip.addItem("Thailand","TH"); dropdownClip.addItem("Togo","TG"); dropdownClip.addItem("Tokelau","TK"); dropdownClip.addItem("Tonga","TO"); dropdownClip.addItem("Trinidad And Tobago","TT"); dropdownClip.addItem("Tunisia","TN"); dropdownClip.addItem("Turkey","TR"); dropdownClip.addItem("Turkmenistan","TM"); dropdownClip.addItem("Turks And Caicos Islands","TC"); dropdownClip.addItem("Tuvalu","TV"); dropdownClip.addItem("Uganda","UG"); dropdownClip.addItem("Ukraine","UA"); dropdownClip.addItem("United Arab Emirates","AE"); dropdownClip.addItem("United States Minor Is.","UM"); dropdownClip.addItem("Uruguay","UY"); dropdownClip.addItem("Uzbekistan","UZ"); dropdownClip.addItem("Vanuatu","VU"); dropdownClip.addItem("Venezuela","VE"); dropdownClip.addItem("Viet Nam","VN"); dropdownClip.addItem("Virgin Islands (British)","VG"); dropdownClip.addItem("Virgin Islands (U.S.)","VI"); dropdownClip.addItem("Wallis And Futuna Islands","WF"); dropdownClip.addItem("Western Sahara","EH"); dropdownClip.addItem("Yemen","YE"); dropdownClip.addItem("Yugoslavia","YU"); dropdownClip.addItem("Zaire","ZR"); dropdownClip.addItem("Zambia","ZM"); dropdownClip.addItem("Zimbabwe","ZW"); dropdownClip.setSelectedIndex(0); }; this.initMobilesDropdown = function(dropdownClip) { mobiles = new Array(); dropdownClip.addItem("Select manufacturer","NIL"); dropdownClip.addItem("NOKIA","NOKIA"); dropdownClip.addItem("MOTOROLA","MOTOROLA"); dropdownClip.addItem("SAMSUNG","SAMSUNG"); dropdownClip.addItem("SONY ERICSSON","ERICSSON"); dropdownClip.addItem("ALCATEL","ALCATEL"); dropdownClip.addItem("LG","LG"); dropdownClip.addItem("NEC","NEC"); dropdownClip.addItem("PANASONIC","PANASONIC"); dropdownClip.addItem("SAGEM","SAGEM"); dropdownClip.addItem("SIEMENS","SIEMENS"); dropdownClip.addItem("SHARP","SHARP"); dropdownClip.addItem("TRIUM","TRIUM"); dropdownClip.addItem("HANDSPRING","HANDSPRING"); dropdownClip.addItem("POGO","POGO"); dropdownClip.setSelectedItem(0); }; this.initDateDropdowns = function(dropdownYear, dropdownMonth, dropdownDay) { dropdownDay.addItem("DD"); var _loc1_ = 1; while(_loc1_ <= 31) { dropdownDay.addItem(_loc1_,_loc1_); _loc1_ = _loc1_ + 1; } dropdownDay.setSelectedIndex(0); dropdownMonth.addItem("MM"); _loc1_ = 1; while(_loc1_ <= 12) { dropdownMonth.addItem(_loc1_,_loc1_); _loc1_ = _loc1_ + 1; } dropdownMonth.setSelectedIndex(0); dropdownYear.addItem("YYYY"); _loc1_ = 2007; while(_loc1_ >= 1900) { dropdownYear.addItem(_loc1_,_loc1_); _loc1_ = _loc1_ - 1; } dropdownYear.setSelectedIndex(0); }; }; initSounds(); _root.objSounds.play("voice-title"); var objSO = SharedObject.getLocal("hannainachoppa"); if(objSO.data.controls == undefined) { objSO.data.sensitivity = "normal"; objSO.data.controls = "easy"; objSO.flush(); } _root.controls = objSO.data.controls; _root.sensitivity = objSO.data.sensitivity; reportAllStatistics(true);